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

hermesCommand in react.gradle uses wrong path - custom folder structure + release build #28126

Closed
nokite opened this issue Feb 19, 2020 · 4 comments
Labels
Needs: Triage 🔍 Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@nokite
Copy link

nokite commented Feb 19, 2020

Description:

My Gradle sync fails when doing a release build on Android since I enabled Hermes. I'm on react-native 0.61.5. Error:

Cannot run program "../../node_modules/hermes-engine/osx-bin/hermes" (in directory "/Users/user/Documents/Projects/MyProject-Android/app"):

The problem is that it assumes a wrong folder structure and can't find the file. The actual structure has both the "app" and "node_modules" folders at the top, and that's configured in react-native.config.js, hopefully correctly...

React Native version:

System:
    OS: macOS 10.15.3
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 57.12 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 13.8.0 - /var/folders/lh/vlsw338n0n98mp7s0gc6_46c0000gn/T/yarn--1582124025747-0.01396295552913096/node
    Yarn: 1.22.0 - /var/folders/lh/vlsw338n0n98mp7s0gc6_46c0000gn/T/yarn--1582124025747-0.01396295552913096/yarn
    npm: 6.13.7 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 28, 29
      Build Tools: 28.0.3, 29.0.2
      System Images: android-21 | Google APIs Intel x86 Atom, android-22 | Google APIs Intel x86 Atom, android-24 | Google Play Intel x86 Atom, android-25 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.6010548
    Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0 
    react-native: 0.61.5 => 0.61.5

Steps To Reproduce

  1. Install a react-native Android project with custom folder structure, as described below.
  2. Enable Hermes.
  3. Do a release build.
  4. It fails during gradle sync because the hermesCommand uses the wrong root path.

Expected Results

The gradle build completes successfully in release mode (just like it does in Debug mode)

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

The folder structure follows a regular Android project. We use ReactNative only for a small component, so we don't want to modify the whole structure.
Folder structure

root
- app (with Android sources)
- node_modules
- package.json
- react-native.config.js
- build.gradle (etc)

react-native.config.js

const android = require('@react-native-community/cli-platform-android');

module.exports = {
  project: {
    android: {
      sourceDir: '.',
    },
  },
  platforms: {
    android: {
      linkConfig: android.linkConfig,
      projectConfig: android.projectConfig,
      dependencyConfig: android.dependencyConfig,
    },
  },
};

I believe the issue comes from this line:

def hermesCommand = config.hermesCommand ?: "../../node_modules/hermes-engine/%OS-BIN%/hermes"

def hermesCommand = config.hermesCommand ?: "../../node_modules/hermes-engine/%OS-BIN%/hermes"

When I change "../../node_modules" to "../node_modules" the build succeeds.

@nokite nokite changed the title hermesCommand in react.gradle uses wrong path when folder structure is custom, for release builds hermesCommand in react.gradle uses wrong path - custom folder structure, release build Feb 19, 2020
@nokite nokite changed the title hermesCommand in react.gradle uses wrong path - custom folder structure, release build hermesCommand in react.gradle uses wrong path - custom folder structure + release build Feb 19, 2020
@mjmasn
Copy link
Contributor

mjmasn commented Feb 19, 2020

@nokite this doesn't seem like a bug seeing as you have a custom directory structure. Have you tried specifying hermesCommand in your build.gradle?

For example:

project.ext.react = [
    entryFile: "index.js",
    enableHermes: true, // clean and rebuild if changing,
    hermesCommand: "../node_modules/hermes-engine/%OS-BIN%/hermes", // Or whatever path you need
]

I haven't tried this but it looks like it should work :)

@nokite
Copy link
Author

nokite commented Feb 19, 2020

@mjmasn This works, thanks!
I realize that I was missing insight into how to use this, and this is not necessarily a bug, as it's configurable. 👍

This makes me think that I could have used better documentation. It would have been useful to find a few words about configuring projects with non-default structure. I had trouble finding out how to properly set it up, and it only added to the headache of upgrading from 0.59.8 to 0.61.5. (as my project structure was not problematic on 0.59.8)

@stale
Copy link

stale bot commented May 19, 2020

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label May 19, 2020
@stale
Copy link

stale bot commented May 30, 2020

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed May 30, 2020
@facebook facebook locked as resolved and limited conversation to collaborators May 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs: Triage 🔍 Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

2 participants