Skip to content

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

@nokite

Description

@nokite

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Triage 🔍StaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions