Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error build release (hermes enable) #34116

Closed
cervisebas opened this issue Jul 1, 2022 · 9 comments
Closed

Error build release (hermes enable) #34116

cervisebas opened this issue Jul 1, 2022 · 9 comments

Comments

@cervisebas
Copy link

Description

Console out:

FAILURE: Build failed with an exception.

  • Where:
    Script 'C:\Users\cervi\Desktop\Escuela\proyecto-asistencia@Reset2\TecnicaDigital\node_modules\react-native\react.gradle' line: 126

  • What went wrong:
    Execution failed for task ':app:bundleReleaseJsAndAssets'.

java.lang.Exception: Couldn't determine Hermesc location. Please set project.ext.react.hermesCommand to the path of the hermesc binary file. node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc

Version

0.69.1

Output of npx react-native info

System:
OS: Windows 10 10.0.22000
CPU: (4) x64 Intel(R) Core(TM) i3-7020U CPU @ 2.30GHz
Memory: 1.92 GB / 7.88 GB
Binaries:
Node: 16.13.1 - ~\AppData\Local\Temp\yarn--1656711531736-0.4762878003872508\node.CMD
Yarn: 1.22.19 - ~\AppData\Local\Temp\yarn--1656711531736-0.4762878003872508\yarn.CMD
npm: 8.12.2 - C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK:
API Levels: 28, 29, 30, 31, 32
Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.2, 30.0.3, 31.0.0, 32.0.0, 32.1.0, 33.0.0
System Images: android-24 | Google APIs Intel x86 Atom, android-27 | Google APIs Intel x86 Atom
Android NDK: 23.1.7779620
Windows SDK:
AllowDevelopmentWithoutDevLicense: Enabled
AllowAllTrustedApps: Enabled
Versions: 10.0.10240.0, 10.0.17763.0, 10.0.18362.0, 10.0.19041.0
IDEs:
Android Studio: Version 2021.1.0.0 AI-211.7628.21.2111.8193401
Visual Studio: 15.9.28307.1919 (Visual Studio Community 2017), 16.11.32407.337 (Visual Studio Community 2019)
Languages:
Java: 11.0.13 - C:\Program Files\Common Files\Oracle\Java\javapath\javac.EXE
npmPackages:
@react-native-community/cli: Not Found
react: 18.2.0 => 18.2.0
react-native: 0.69.1 => 0.69.1
react-native-windows: Not Found
npmGlobalPackages:
react-native: Not Found

Steps to reproduce

.

Snack, code example, screenshot, or link to a repository

.

@JoseLion
Copy link
Contributor

JoseLion commented Jul 4, 2022

I faced the same issue with a new application created with react-native init. The problem is that the hermesCommand extra property is missing in the app-level build.gradle file. I solved the problem by adding the correct Hermes Command path, like so:

project.ext.react = [
    enableHermes: true,  // clean and rebuild if changing
    hermesCommand: '../../node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc'
]

NOTE: Setting the path to ../../node_modules/hermes-engine/%OS-BIN%/hermesc instead will cause a conflict between Hermes versions, which will throw the runtime error Compiling JS failed: Wrong bytecode version. Expected 85 but got 84, causing the app to crash as soon as it starts.

I hope this helps 🙂

@aleluiah
Copy link

aleluiah commented Jul 4, 2022

@cervisebas were you able to build successfully on windows 10 i have been having error with my build on windows checkout the issue here #34084

@cortinico
Copy link
Contributor

I solved the problem by adding the correct Hermes Command path, like so:

Thanks for sharing this @JoseLion That sounds like a potential bug though.
The hermesCommand config has a sensible default which is the same value you're setting:

react-native/react.gradle

Lines 117 to 124 in 71e8921

// 3. If the react-native contains a pre-built hermesc, use it.
def prebuiltHermesPath = "node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc"
.replaceAll("%OS-BIN%", getHermesOSBin())
.replace('/' as char, File.separatorChar);
def prebuiltHermes = new File(reactRoot, prebuiltHermesPath)
if (prebuiltHermes.exists()) {
return prebuiltHermes.getAbsolutePath()
}

I wonder why you had to specify this value again.

@JoseLion
Copy link
Contributor

JoseLion commented Jul 7, 2022

@cortinico good point! I think I found the problem, and now it makes sense that it's only affecting Windows users.

The prebuiltHermes file is created with a path like C:\path\to\my\app\node_modules\react-native\sdks\hermesc\win64-bin\hermesc which then is checked with prebuiltHermes.exists(). The path to the HermesC folder is correct, but on Windows, the file hermesc will never exist because the file is actually hermesc.exe.

I think a simple solution could be to have a variable with the correct binary file depending on the OS:

def hermescBin = Os.isFamily(Os.FAMILY_WINDOWS) ? 'hermesc.exe' : 'hermesc'

I'll be happy to open a PR with this change if you agree it's a good approach 🙂

@wfern
Copy link
Contributor

wfern commented Jul 7, 2022

I can confirm the @JoseLion's fix, adding ".exe" in the file path works:

// 3. If the react-native contains a pre-built hermesc, use it.
def hermescBin = Os.isFamily(Os.FAMILY_WINDOWS) ? 'hermesc.exe' : 'hermesc'
def prebuiltHermesPath = ("node_modules/react-native/sdks/hermesc/%OS-BIN%/" + hermescBin)
        .replaceAll("%OS-BIN%", getHermesOSBin())
        .replace('/' as char, File.separatorChar);

Thanks @JoseLion!

@JoseLion
Copy link
Contributor

JoseLion commented Jul 7, 2022

I opened PR #34151 with this fix. I hope this helps 🎉

@nibblesnbits
Copy link

nibblesnbits commented Jul 7, 2022

Added changes to my local react.gradle, and see the effect, but it still fails for me on a new project when I run gradlew clean.

> Task :ReactAndroid:hermes-engine:buildCMakeRelease[arm64-v8a][libhermes] FAILED
C/C++: ninja: error: 'C:/git-other/ostrichv2native/node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/Release/hermesc.exe', needed by 'lib/InternalBytecode/InternalBytecode.hbc', missing and no known rule to make it

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':ReactAndroid:hermes-engine:buildCMakeRelease[arm64-v8a][libhermes]'.
> Build command failed.
  Error while executing process C:\Users\sgcol\AppData\Local\Android\Sdk\cmake\3.18.1\bin\ninja.exe with arguments {-C C:\git-other\ostrichv2native\node_modules\react-native\ReactAndroid\hermes-engine\.cxx\Release\t4zh3s1n\arm64-v8a libhermes}
  ninja: Entering directory `C:\git-other\ostrichv2native\node_modules\react-native\ReactAndroid\hermes-engine\.cxx\Release\t4zh3s1n\arm64-v8a'

  ninja: error: 'C:/git-other/ostrichv2native/node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/Release/hermesc.exe', needed by 'lib/InternalBytecode/InternalBytecode.hbc', missing and no known rule to make it

Similar when running npm run android

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
CMake Deprecation Warning at CMakeLists.txt:42 (cmake_policy):
  The OLD behavior for policy CMP0026 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


Using Windows 10 built-in ICU

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':ReactAndroid:hermes-engine:buildCMakeRelease[arm64-v8a][libhermes]'.
> Build command failed.
  Error while executing process C:\Users\sgcol\AppData\Local\Android\Sdk\cmake\3.18.1\bin\ninja.exe with arguments {-C C:\git-other\ostrichv2native\node_modules\react-native\ReactAndroid\hermes-engine\.cxx\Release\t4zh3s1n\arm64-v8a libhermes}
  ninja: Entering directory `C:\git-other\ostrichv2native\node_modules\react-native\ReactAndroid\hermes-engine\.cxx\Release\t4zh3s1n\arm64-v8a'

  ninja: error: 'C:/git-other/ostrichv2native/node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/Release/hermesc.exe', needed by 'lib/InternalBytecode/InternalBytecode.hbc', missing and no known rule to make it

C:\git-other\ostrichv2native\node_modules\react-native\ReactAndroid\hermes-engine\build\hermes\bin\Debug\hermesc.exe exists, but the Release and MinSizeRel versions never get built.

@JoseLion
Copy link
Contributor

@nibblesnbits I think the path for hermesc is incorrect when hermes-engine is built from source. Please take a look at this comment for more details 🙂

I can include a fix in the open PR, but I need some help to confirm if the proposed solution fixes the issue since I'm not currently using the new architecture 😅

kelset pushed a commit that referenced this issue Aug 11, 2022
…34151)

Summary:
Resolves #34116.

In a nutshell, the problem was a missing `.exe` extension on the `hermesc` binary path when running on Windows OS. The missing extension causes the method `.exists()` of the File instance to always return false, so none of the conditions ever met and an error was thrown whenever a release build with Hermes enabled was run on Windows. More details can be found in the comments on the above issues.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Android] [Fixed] - Fix error of release builds with Hermes enabled for Windows users

Pull Request resolved: #34151

Test Plan:
### Reproduce

Changes on Gradle scrips are better tested on an actual application. To reproduce the issue you can:
1. Create or reuse a React Native application with version `v0.69.1` on a Windows machine
2. Enable Hermes on Android following the steps on the [documentation](https://reactnative.dev/docs/hermes#enabling-hermes)
3. Clean the build folder: `cd android && ./gradlew clean`
4. Bundle the JS and assets for a release version: `./gradlew bundleReleaseJsAndAssets`
5. The build fails with the following error:
```shell
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> java.lang.Exception: Couldn't determine Hermesc location. Please set `project.ext.react.hermesCommand` to the path of the hermesc binary file. node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc
```

### Test the changes

Follow the same steps above using the fix on this PR and the error should disappear 🙂

Reviewed By: NickGerleman

Differential Revision: D37755468

Pulled By: cortinico

fbshipit-source-id: 2ad0ced583555b907259df116f64a45da6d153f3
roryabraham pushed a commit to Expensify/react-native that referenced this issue Aug 17, 2022
…acebook#34151)

Summary:
Resolves facebook#34116.

In a nutshell, the problem was a missing `.exe` extension on the `hermesc` binary path when running on Windows OS. The missing extension causes the method `.exists()` of the File instance to always return false, so none of the conditions ever met and an error was thrown whenever a release build with Hermes enabled was run on Windows. More details can be found in the comments on the above issues.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Android] [Fixed] - Fix error of release builds with Hermes enabled for Windows users

Pull Request resolved: facebook#34151

Test Plan:
### Reproduce

Changes on Gradle scrips are better tested on an actual application. To reproduce the issue you can:
1. Create or reuse a React Native application with version `v0.69.1` on a Windows machine
2. Enable Hermes on Android following the steps on the [documentation](https://reactnative.dev/docs/hermes#enabling-hermes)
3. Clean the build folder: `cd android && ./gradlew clean`
4. Bundle the JS and assets for a release version: `./gradlew bundleReleaseJsAndAssets`
5. The build fails with the following error:
```shell
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> java.lang.Exception: Couldn't determine Hermesc location. Please set `project.ext.react.hermesCommand` to the path of the hermesc binary file. node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc
```

### Test the changes

Follow the same steps above using the fix on this PR and the error should disappear 🙂

Reviewed By: NickGerleman

Differential Revision: D37755468

Pulled By: cortinico

fbshipit-source-id: 2ad0ced583555b907259df116f64a45da6d153f3
roryabraham pushed a commit to Expensify/react-native that referenced this issue Aug 17, 2022
…acebook#34151)

Summary:
Resolves facebook#34116.

In a nutshell, the problem was a missing `.exe` extension on the `hermesc` binary path when running on Windows OS. The missing extension causes the method `.exists()` of the File instance to always return false, so none of the conditions ever met and an error was thrown whenever a release build with Hermes enabled was run on Windows. More details can be found in the comments on the above issues.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Android] [Fixed] - Fix error of release builds with Hermes enabled for Windows users

Pull Request resolved: facebook#34151

Test Plan:
### Reproduce

Changes on Gradle scrips are better tested on an actual application. To reproduce the issue you can:
1. Create or reuse a React Native application with version `v0.69.1` on a Windows machine
2. Enable Hermes on Android following the steps on the [documentation](https://reactnative.dev/docs/hermes#enabling-hermes)
3. Clean the build folder: `cd android && ./gradlew clean`
4. Bundle the JS and assets for a release version: `./gradlew bundleReleaseJsAndAssets`
5. The build fails with the following error:
```shell
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> java.lang.Exception: Couldn't determine Hermesc location. Please set `project.ext.react.hermesCommand` to the path of the hermesc binary file. node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc
```

### Test the changes

Follow the same steps above using the fix on this PR and the error should disappear 🙂

Reviewed By: NickGerleman

Differential Revision: D37755468

Pulled By: cortinico

fbshipit-source-id: 2ad0ced583555b907259df116f64a45da6d153f3
@Suryanshshukla24
Copy link

add this in dependencies

def hermesPath = "../../node_modules/hermes-engine/android/"
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")

inside if section

like this

   if (enableHermes) {
    def hermesPath = "../../node_modules/hermes-engine/android/"
    debugImplementation files(hermesPath + "hermes-debug.aar")
    releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
    implementation jscFlavor
}

agustinruiz added a commit to agustinruiz/galoy-mobile that referenced this issue Oct 28, 2022
…ocation. Please set project.ext.react.hermesCommand to the path of the hermesc binary file. node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc". Se encontro en facebook/react-native#34116
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants