cli: ERROR: autolinkLibrariesFromCommand: process npx @react-native-community/cli config exited with error code: 126
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/openjdk@1.17.0/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 https://github.com/react-native-community/cli/issues/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 https://github.com/react-native-community/cli/issues/2490#issuecomment-2323146345 mentions making rnc-cli executable but mine already is executable.
Same error as this comment https://github.com/facebook/react-native/issues/46134#issuecomment-2316052971 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/openjdk@1.17.0/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
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 32
@cripttion an easy workaround is to do
chmod u+x node_modules/@react-native-community/cli/build/*.jswhenever you bump into this error after updating node modules.@cripttion sure, don’t use Windows for RN (nor for any other non-Windows) development 🤣
It looks like permissions issue as I did the same:
chmod +x /Users/[RN-PROJECT-PATH]/node_modules/.bin/rnc-cliand the build started without the reported error…
Well that didn’t last long, tried another build after working on the app and the same error has returned.
Running
./gradlew -stopand then starting a new build seems to work.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.
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 && yarnI just ran into the same issue. For me, doing a
chmod +xon thernc-climade it work again. I also tried running theinitas suggested above before doing the permission thingy, that didn’t solve it for me 🤷♂️Using Node 20 solve my issue
As Paurox mentioned, the package name/namespace seems to affect this issue. I had also encountered this issue multiple times so far, and the cause seems to alter everytime. The main problem, as the error mentioned, is that
npx @react-native-community/cli configdoesn’t provide a correct output due to some reasons. This could be a permission issue, or the command actually doesn’t work, or in rare cases, you may need to update thesettings.gradlefile, and lastly, you may also have an outdated nodejs version like 16.The permission issue can be ressolved by using
chmodor run as admin on Windows (not recommended though). When the command doesn’t work, try updating@react-native-community/clito the latest version because the latest 0.76.3 template uses a version, 15.0.1, which doesn’t work at least for me. In the third case, it is probably due to the folder structure, so theautolinkLibrariesFromCommandfunction needs to be updated like the following:See the whole settings.gradle
Also, make sure the node version is up to date, I had node 16 previously, so it worked until it didn’t. Try the good old remove
node_modulescould be another way. I also had some issues due tonvm, somehow Xcode or Android Studio couldn’t locate the correct version and was using the system node.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.
Worked Like a Magic!