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: autolinkLibrariesFromCommand: process npx @react-native-community/cli config exited with error code: 126 #2498

Open
evoactivity opened this issue Sep 7, 2024 · 23 comments

Comments

@evoactivity
Copy link

evoactivity commented Sep 7, 2024

Environment

react-native info output
System:
  OS: macOS 14.2.1
  CPU: (10) arm64 Apple M1 Max
  Memory: 941.36 MB / 64.00 GB
  Shell:
    version: 3.6.0
    path: /opt/homebrew/bin/fish
Binaries:
  Node:
    version: 18.18.0
    path: ~/.volta/tools/image/node/18.18.0/bin/node
  Yarn:
    version: 3.6.4
    path: ~/.volta/tools/image/yarn/1.22.18/bin/yarn
  npm:
    version: 9.8.1
    path: ~/.volta/tools/image/node/18.18.0/bin/npm
  Watchman:
    version: 2024.08.26.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK:
    API Levels:
      - "31"
      - "32"
      - "33"
      - "34"
    Build Tools:
      - 30.0.3
      - 31.0.0
      - 33.0.0
      - 33.0.1
      - 34.0.0
    System Images:
      - android-31 | Google TV ARM 64 v8a
      - android-32 | Google APIs ARM 64 v8a
      - android-33 | Google APIs ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.18034.62.2412.12266719
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: javac 17
    path: /Users/liam/.jabba/jdk/[email protected]/Contents/Home/bin/javac
  Ruby:
    version: 3.3.4
    path: /opt/homebrew/opt/ruby/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 14.0.1
    wanted: ^14.0.1
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native: Not Found
  react-native-macos: Not Found
  react-native-tvos:
    installed: 0.75.2-0
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Description

I'm seeing a similar problem as #2490 but with a different exit code.

Caused by: org.gradle.api.GradleException: ERROR: autolinkLibrariesFromCommand: process npx @react-native-community/cli config exited with error code: 126

Which usually means a permissions issue. I can run npx @react-native-community/cli config myself with no issues.
This comment #2490 (comment) mentions making rnc-cli executable but mine already is executable.

Same error as this comment facebook/react-native#46134 (comment) but that issue is unrelated so suggested fixes don't work.

When I run the build from android studio it doesn't run into this (but does error about dependencies being built against wrong SDK version so I can't complete a build from there).

I've tried ./gradlew clean but that results in the same error, I've deleted node_modules and lockfile, I've tried looking manually at the cli bin files for permission issues, I've updated android studio, I'm using latest SDK.

I tried running as root and then it was able to build, but that causes a bunch of other issues related to file ownership being owned by root.

Building when running on emulator (from react-native start) works fine and I can work on the app like normal.

This began happening updgrading from 0.73.7 to 0.75.2 (through the react-native-tvos project).

This happens when building using

./gradlew assembleRelease

I'm using volta to manage node versions

Reproducible Demo

I was able to reproduce in a fresh project

$ npx @react-native-community/cli init testproject
$ cd testproject
$ yarn
$ cd android
$ ./gradlew assembleRelease --info --verbose --full-stacktrace    
react-native info output
  System:
  OS: macOS 14.2.1
  CPU: (10) arm64 Apple M1 Max
  Memory: 305.52 MB / 64.00 GB
  Shell:
    version: 3.6.0
    path: /opt/homebrew/bin/fish
Binaries:
  Node:
    version: 18.17.1
    path: ~/.volta/tools/image/node/18.17.1/bin/node
  Yarn:
    version: 3.6.4
    path: ~/.volta/tools/image/yarn/1.22.18/bin/yarn
  npm:
    version: 9.6.7
    path: ~/.volta/tools/image/node/18.17.1/bin/npm
  Watchman:
    version: 2024.08.26.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK:
    API Levels:
      - "31"
      - "32"
      - "33"
      - "34"
    Build Tools:
      - 30.0.3
      - 31.0.0
      - 33.0.0
      - 33.0.1
      - 34.0.0
    System Images:
      - android-31 | Google TV ARM 64 v8a
      - android-32 | Google APIs ARM 64 v8a
      - android-33 | Google APIs ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.18034.62.2412.12266719
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: javac 17
    path: /Users/liam/.jabba/jdk/[email protected]/Contents/Home/bin/javac
  Ruby:
    version: 3.3.4
    path: /opt/homebrew/opt/ruby/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.75.2
    wanted: 0.75.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: false
@evoactivity
Copy link
Author

Building with react-native build-android --mode release works but I'm trying to generate an apk file not an aab file.

@evoactivity
Copy link
Author

Downgrading from gradle 8.8 to 8.7 seems to have fixed things but I also had it working on 8.8 somehow, and then it broke again, so I'll see how long this keeps working.

I had upgraded gradle to 8.8 following the upgrade helper diff
https://react-native-community.github.io/upgrade-helper/?from=0.73.7&to=0.75.2#RnDiffApp-android-gradle-wrapper-gradle-wrapper.properties

@evoactivity
Copy link
Author

Well that didn't last long, tried another build after working on the app and the same error has returned.

Running ./gradlew -stop and then starting a new build seems to work.

@manishgautam12
Copy link

I believe this issue is related to the new version. Last night, a friend and I spent a considerable amount of time troubleshooting, and after extensive efforts, my friend suggested that we try creating the project using the following command:

npx @react-native-community/cli@latest init ProjectName --version 0.74.5

After creating the project with this command, the issue was successfully resolved.

@winterdouglas
Copy link

I just ran into the same issue.
For me, doing a chmod +x on the rnc-cli made it work again.
I also tried running the init as suggested above before doing the permission thingy, that didn't solve it for me 🤷‍♂️

@szymonrybczak
Copy link
Collaborator

@winterdouglas what OS are you using?

@winterdouglas
Copy link

@winterdouglas what OS are you using?

MacOS Sonoma (14.6.1)

@szymonrybczak
Copy link
Collaborator

@winterdouglas in your case does it also happen in fresh projects?

@winterdouglas
Copy link

@winterdouglas in your case does it also happen in fresh projects?

Hm, I haven't tried that before, but doing it now worked right away for a new project.

@birdofpreyru
Copy link

Sounds very similar to my trouble with it since upgrading to v0.75.2 (but I'm getting 127 error code): #2484

@cripttion
Copy link

I am also getting same Error in using any new module when I download any new module it show the error ERROR: autolinkLibrariesFromCommand: process cmd /c npx @react-native-community/cli config exited with error code: 1. Can any one suggest how to solve this

@birdofpreyru
Copy link

@cripttion an easy workaround is to do chmod u+x node_modules/@react-native-community/cli/build/*.js whenever you bump into this error after updating node modules.

@cripttion
Copy link

@birdofpreyru I am using Windows OS can you give any suggestion for this.

@birdofpreyru
Copy link

@cripttion sure, don't use Windows for RN (nor for any other non-Windows) development 🤣

@adirimia92
Copy link

adirimia92 commented Sep 12, 2024

I added the package attribute to the AndroidManifest.xml

Updated my project dependencies by adding @react-native-community/cli:

"@react-native-community/cli": "^14.1.1"
Deleted the node_modules folder and reinstalled the dependencies by running:

Navigated to the Android folder and ran the following Gradle commands to stop and clean the build:

./gradlew -stop
./gradlew clean
After doing this, my build started working successfully.

@Masahito-I
Copy link

Masahito-I commented Sep 12, 2024

I faced this issue, too. I could run my app without any issue yesterday though.

P.S. adirimia92's suggestion worked for me. Thank you.

@Bekaxp
Copy link

Bekaxp commented Sep 17, 2024

I just ran into the same issue. For me, doing a chmod +x on the rnc-cli made it work again. I also tried running the init as suggested above before doing the permission thingy, that didn't solve it for me 🤷‍♂️

It looks like permissions issue as I did the same:
chmod +x /Users/[RN-PROJECT-PATH]/node_modules/.bin/rnc-cli

and the build started without the reported error...

@cam-shaw
Copy link

cam-shaw commented Sep 20, 2024

I added the package attribute to the AndroidManifest.xml

Updated my project dependencies by adding @react-native-community/cli:

"@react-native-community/cli": "^14.1.1" Deleted the node_modules folder and reinstalled the dependencies by running:

Navigated to the Android folder and ran the following Gradle commands to stop and clean the build:

./gradlew -stop ./gradlew clean After doing this, my build started working successfully.

I just ran these two commands for gradle and it worked without the other changes 👍

In the process though I also updated Android Studio, updated all SDKs, deleted node_modules and reinstalled. Hopefully none of those things you'll need to repeat.

@22419914ksa
Copy link

Using Node 20 solve my issue

@DiogoPangea
Copy link

I added the package attribute to the AndroidManifest.xml

Updated my project dependencies by adding @react-native-community/cli:

"@react-native-community/cli": "^14.1.1" Deleted the node_modules folder and reinstalled the dependencies by running:

Navigated to the Android folder and ran the following Gradle commands to stop and clean the build:

./gradlew -stop ./gradlew clean After doing this, my build started working successfully.

./gradlew clean is giving me the same error:

ERROR: autolinkLibrariesFromCommand: process npx @react-native-community/cli config exited with error code: 1

FAILURE: Build failed with an exception.

  • Where:
    Settings file '/Users/[path-to-file]/settings.gradle' line: 3

  • What went wrong:
    A problem occurred evaluating settings 'pangea'.

ERROR: autolinkLibrariesFromCommand: process npx @react-native-community/cli config exited with error code: 1

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org.

BUILD FAILED in 1s

@malinjr07
Copy link

.bin/rnc-cli

Worked Like a Magic!

@xiangjiu0918
Copy link

我在AndroidManifest.xml中添加了package属性
通过添加@react-native-community/cli更新了我的项目依赖项:
“@react-native-community/cli”:“^14.1.1” 删除 node_modules 文件夹并通过运行重新安装依赖项:
导航到 Android 文件夹并运行以下 Gradle 命令来停止并清理构建:
./gradlew -stop ./gradlew clean 完成此操作后,我的构建开始成功运行。

./gradlew clean 给了我同样的错误:

错误:autolinkLibrariesFromCommand:进程 npx @react-native-community/cli 配置退出,错误代码:1

失败:构建因异常而失败。

  • 其中:
    设置文件'/Users/[path-to-file]/settings.gradle' 行:3
  • 出了什么问题:
    评估“pangea”设置时出现问题。

错误:autolinkLibrariesFromCommand:进程 npx @react-native-community/cli 配置退出,错误代码:1

  • 尝试:

使用 --stacktrace 选项运行以获取堆栈跟踪。
使用 --info 或 --debug 选项运行以获取更多日志输出。
使用 --scan 运行以获取完整见解。在https://help.gradle.org
上获取更多帮助。

1 秒内构建失败

我遇到了同样的问题

@exzos28
Copy link

exzos28 commented Nov 14, 2024

Guys who are looking for solutions to this, then just uninstall node_modules and install the dependencies again.
Something strange happens with cli when switching to other branches.

rm -rf node_modules && yarn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests