react-native: Running first init project Error React-rncore: Command PhaseScriptExecution failed with a nonzero exit code
Description
I’m just trying to run a newly initialized React Native project.
React Native Version
0.72.5
Output of npx react-native info
System: OS: macOS 14.0 CPU: (8) arm64 Apple M2 Memory: 129.89 MB / 8.00 GB Shell: version: “5.9” path: /bin/zsh Binaries: Node: version: 18.12.1 path: ~/.nvm/versions/node/v18.12.1/bin/node Yarn: Not Found npm: version: 8.19.2 path: ~/.nvm/versions/node/v18.12.1/bin/npm Watchman: version: 2023.09.18.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.13.0 path: /Users/fachrinfl/.rvm/gems/ruby-2.7.7/bin/pod SDKs: iOS SDK: Platforms: - DriverKit 23.0 - iOS 17.0 - macOS 14.0 - tvOS 17.0 - watchOS 10.0 Android SDK: Not Found IDEs: Android Studio: 2022.2 AI-222.4459.24.2221.9971841 Xcode: version: 15.0/15A240d path: /usr/bin/xcodebuild Languages: Java: version: 11.0.19 path: /opt/homebrew/opt/openjdk@11/bin/javac Ruby: version: 2.7.7 path: /Users/fachrinfl/.rvm/rubies/ruby-2.7.7/bin/ruby npmPackages: “@react-native-community/cli”: Not Found react: installed: 18.2.0 wanted: 18.2.0 react-native: installed: 0.72.5 wanted: 0.72.5 react-native-macos: Not Found npmGlobalPackages: “react-native”: Not Found Android: hermesEnabled: true newArchEnabled: false iOS: hermesEnabled: true newArchEnabled: false
Steps to reproduce
npx react-native init AwesomeProject xed -b ios Running via XCode
Snack, screenshot, or link to a repository
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 15
- Comments: 100 (1 by maintainers)
Solved. In my case, the problem occurred if the parent folder names contained whitespaces. Removing whitespaces in folder names fixed the problem
I encountered a similar issue on an existing project after I run
brew upgradeon my mac, which updated Node version from 18.17.0 to 18.18.0. In the end the issue was that theios/.xcode.env.localfile that gets generated the first time you runpod install, had a hard coded path to the 18.17.0 Node version, which didn’t exist anymore. So fixing that file fixed the build. This doesn’t however explain why you would have this issue on a new project, but probably good idea to check what that file contains 🤔Same issue here with Xcode 15.0.1 on macOS Sonoma.
In my case i solved it setting the correct path to the nodejs version that my project needs, i don’t know why but xcode was using another.
To do it i had to create the file .xcode.env.local inside my ios folder and set the next path NODE_BINARY=“/opt/homebrew/Cellar/node@16/16.20.2/bin/node”
Same thing here. I solved my issue by removing a whitespace in one of the parent folders
solution. There should be no empty space in the names of folders managing the project. and worked for me
me too has this error
Exact same issue here, using Xcode 15 (public version not beta) on macOS Sonoma. Tried both on 0.72.5 and 0.72.4. Also on an M2 chip.
Building and running the app still works fine with “react-native start” and fastlane, but when trying to build through Xcode this error keeps occurring after the update to Sonoma
I have M3 Pro Macbook Pro and the issue was due to whitespaces in the directory name. Make sure to remove whitespaces in the parent directories as well
I still have this problem and there are no white spaces in the name of the parent folder so it’s not really that.
Had the same issue, fixed by setting the
export NODE_BINARY="/opt/homebrew/bin/node"in .xcode.env.localPath /opt/homebrew/bin/node is coming from
which nodecommandI am facing same issues.
and
I see in logs that some command from the script uses
cpwith invalid optionThis option is present in native cp (
/bin/cp), so the solution would be to patchsame issue i am suffering this problem last 10 days “React-rncore command phasescriptexecution failed with a nonzero exit code” system Mac m2 xcode version 15 react native version 0.72 note: properly working on Intel chipset mac
This commit fixed it for me: (rn 0.73.0)
https://github.com/facebook/react-native/commit/9f28616650a61ca298c2fc710b588445b8ceb94c
I was getting this back:
The
IP=was empty so after running this on my terminalipconfig getifaddr en0it returned nothing whileipconfig getifaddr en1returned my machine’s IP address. After visitingreact-native/scripts/react-native-xcode.shon this repo I found out about the commit mentioned above that fixed it for me.Worth mentioning that the build error was happening only when building on real device, on simulator the build has no issues.
In my case just solved by
hopefully worked
i cant still run the project @soutua after upgrading node version.
I was able to fix by creating
.xcode.env.localfile (ignored by git)and following steps from here in order to add real path to node binary
Bro Please do one think
did you check you project name existing space or not ?
I faced same issue and found that
cp -R -X "$TEMP_OUTPUT_DIR/." "$RCT_SCRIPT_OUTPUT_DIR" || exit 1https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods_utils/script_phases.sh#L107 was failing due tocp: invalid option -- 'X'. I couldn’t find upper case -X option in cp command from gnu docs and also couldn’t find it in unix posix. So, this script needs to be updated to make it work for different cp commands from different platforms.It works for me
Removing folder with white spaces fixed the problem for me as well. Why in the world. Does anyone know why this may be the case? This means XCode cannot handle white space folders currently?
I am also facing the same issue. after running react-native run-ios it is showing PhaseScriptExecution failed with lots of error. If i scroll up to the top in the terminal I could see something like find: /Users/{user}/Library/Developer/Xcode/DerivedData/{projectname}-aaljqomuvoszdacrlntaoafplcyl/SourcePackages/artifacts: No such file or directory /bin/sh: : No such file or directory Command PhaseScriptExecution failed with a nonzero exit code
get your note path by command "which node ", and change file .Xcode.env export NODE_BINARY=$(command -v node) ===>>>> export NODE_BINARY=“your note path” it use for me!
Thank you so much it’s work for me.
Maybe good to know, I had the same path without the double routes (") after adding the " before and after it worked.
React native version 0.73.5
Edit the node_modules/react-native/scripts/react-native-xcode.sh file
change the first entry “set -x -e” to “set -x” save and rebuild.
I hope it was useful.
@swathycsv what’s status bro have you resolve issue ?
are you facing this error ? @swathycsv
i have solution Please check you project name existing (blank space ) Please remove it
God damnit. You saved my life
@gomestai You made my day
For me, I had to delete the file and rerun
pod installto ‘fix’ it.Thanks for the help!
after wasting around 24 hours. it solved finally
Thanks
thanks a lot!!!!!!
Its also work for me https://www.positioniseverything.net/command-phasescriptexecution-failed-with-a-nonzero-exit-code/ Thanks @gomestai