react-native: Command PhaseScriptExecution failed with a nonzero exit code

Description

Trying to load a public react-native project: https://github.com/dramsay9/reactnative-attentionapp and got the below error in Xcode:

 /bin/sh -c /Users/zhongs/Library/Developer/Xcode/DerivedData/ReactNativeAttentionTestApp-bxdxpymlnyawuofimfjmwtyperdx/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/FBReactNativeSpec.build/Script-5F3DB3CFA631AC0192B75E29E50D22E5.sh

Command PhaseScriptExecution failed with a nonzero exit code 

Configuration did to run this project:

  • Added GoogleService-Info for Firebase
  • Delete Podfile.lock, xcworkspace and pod install
  • Update developer profiles
  • Removed Flipper (as it’s not used and causing errors)

Version

0.67.2

Output of npx react-native info

info Fetching system and libraries information… System: OS: macOS 12.5 CPU: (8) x64 Intel® Core™ i7-8569U CPU @ 2.80GHz Memory: 185.62 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 16.17.0 - ~/.nvm/versions/node/v16.17.0/bin/node Yarn: Not Found npm: 8.15.0 - ~/.nvm/versions/node/v16.17.0/bin/npm Watchman: 2022.08.15.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5 Android SDK: Not Found IDEs: Android Studio: 2021.1 AI-211.7628.21.2111.8193401 Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild Languages: Java: 1.8.0_332-internal - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.67.2 => 0.67.2 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

Both “run” using Xcode and npx react-native run-ios --device “” gives the same error.

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

Results using npx react-native run-ios --device "

** BUILD FAILED **
The following build commands failed:
	PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/zhongs/Library/Developer/Xcode/DerivedData/ReactNativeAttentionTestApp-bxdxpymlnyawuofimfjmwtyperdx/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/FBReactNativeSpec.build/Script-5F3DB3CFA631AC0192B75E29E50D22E5.sh (in target 'FBReactNativeSpec' from project 'Pods')
(1 failure)

react-native doctor:

✓ Node.js
✖ yarn
  - Version found: N/A
  - Version supported: >= 1.10.x
✖ Watchman - Used for watching changes in the filesystem when in development mode
  - Version found: 2022.08.15.00
  - Version supported: 4.x

Android
✓ JDK
✓ Android Studio - Required for building and installing your app on Android
✖ Android SDK - Required for building and installing your app on Android
  - Versions found: N/A
  - Version supported: 30.0.2
✖ ANDROID_HOME

iOS
✓ Xcode - Required for building and installing your app on iOS
✓ CocoaPods - Required for installing iOS dependencies
● ios-deploy - Required for installing your app on a physical device with the CLI

env:

NVM_INC=/Users/zhongs/.nvm/versions/node/v16.17.0/include/node
NVM_RC_VERSION=
TERM_PROGRAM=Apple_Terminal
NVM_CD_FLAGS=
SHELL=/bin/bash
TERM=xterm-256color
TMPDIR=/var/folders/84/85yg3v756w90md_90mkspt3d0j0qsw/T/
TERM_PROGRAM_VERSION=445
OLDPWD=/Users/zhongs/Desktop/React_native/reactnative-attentionapp-main/ios
TERM_SESSION_ID=D150D757-B20D-4816-8388-2F719173DFCA
NVM_DIR=/Users/zhongs/.nvm
USER=zhongs
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.6jxunqy4sX/Listeners
PATH=/Users/zhongs/.nvm/versions/node/v16.17.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands
__CFBundleIdentifier=com.apple.Terminal
PWD=/Users/zhongs/Desktop/MediaLab/visual_comfort/React_native/reactnative-attentionapp-main
XPC_FLAGS=0x0
XPC_SERVICE_NAME=0
SHLVL=1
HOME=/Users/zhongs
LOGNAME=zhongs
LC_CTYPE=UTF-8
NVM_BIN=/Users/zhongs/.nvm/versions/node/v16.17.0/bin
_=/usr/bin/env

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 19

Most upvoted comments

Fixed it by removing ios/.xcode.env & ios/.xcode.env.local files. As I’m using two devices to build and distribute my app, it generates ios/.xcode.env.local file which creates this issue.

If you were a MacOS user, you would have configured your development environment using zsh by default. However, because bash is used in react-native and expo, there is no node setting in bash, which causes an error. In my case, there was an error building the app in xcode. There are no errors in apps created with react-native, but there are errors in apps created with ignite-cli.

The with-node.sh file references .xcode.env, but could not find a node. So I set the path of the node statically.

echo “export NODE_BINARY=$(command -v node)” > ios/.xcode.env.local

After statically setting the node path, the build was successful in xcode.

You shouldn’t use nvm because node_modules/react-native/scripts/find-node.sh file in old React Native can’t find path to node. Removing nvm can resolve your problem. Source: stackoverflow.com/questions/66742033/phasescriptexecution-cp-user-error-in-react-native

Thanks for the link. However, I still have the same error after removing nvm. The environment now:

TERM_PROGRAM=Apple_Terminal
TERM=xterm-256color
SHELL=/bin/bash
TMPDIR=/var/folders/84/85yg3v756w90md_90mkspt3d0j0qsw/T/
TERM_PROGRAM_VERSION=445
ANDROID_SDK_ROOT=/Users/zhongs/Library/Android/sdk
TERM_SESSION_ID=40548996-F6D9-4605-A022-71113EF8D6A4
USER=zhongs
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.aO9ZNPaQ7T/Listeners
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/zhongs/Library/Android/sdk/emulator:/Users/zhongs/Library/Android/sdk/platform-tools
LaunchInstanceID=895054D2-83C0-4384-B00B-B97140DD67DE
__CFBundleIdentifier=com.apple.Terminal
PWD=/xxxxx/reactnative-attention-app-main
XPC_FLAGS=0x0
XPC_SERVICE_NAME=0
HOME=/Users/xx
SHLVL=1
LOGNAME=xx
LC_CTYPE=UTF-8
SECURITYSESSIONID=186a3
_=/usr/bin/env

Some supplementary information: my macbook is not M1; it is 2.8 GHz Quad-Core Intel Core i7.

I can run project you mention without any problem. I suggest you check where node is by running command where node. The path should be /usr/local/bin/node or inside homebrew folder. If you have time, try my project, see if it throw same error or not.

I tried to follow the guideline for creating a new project: https://reactnative.dev/docs/environment-setup and got the error in this post again. So I guess there were some fundamental setup issues. I found this post: https://stackoverflow.com/questions/66742033/phasescriptexecution-cp-user-error-in-react-native and discovered the nvm installed by homebrew that I missed out in the removing process.

So I did the following and finally move on from this error and the app runs 😃. Many thanks!

xx:xx zhongs$ echo $(brew --prefix nvm)
/usr/local/opt/nvm
xx:xx zhongs$ brew uninstall nvm
Uninstalling /usr/local/Cellar/nvm/0.39.1_1... (9 files, 184.1KB)

I managed to fix a similar issue by cleaning and reinstalling the pods after deleting node modules, deleting xcode derived data and reinstall dependencies. I tried to only reinstall pods but it was not enough, removing node-module folder + xcode derived data folder before reinstalling my deps and pods did the trick.

I also encounter this issue. Below is my config settings of react-native info :


info Fetching system and libraries information...

System:
    OS: macOS 14.1
    CPU: (8) arm64 Apple M2
    Memory: 498.81 MB / 24.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 18.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 9.8.1 - /usr/local/bin/npm
    Watchman: 2023.09.25.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.13.0 - /opt/homebrew/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.10121639
    Xcode: 15.0/15A240d - /usr/bin/xcodebuild
  Languages:
    Java: 19.0.1 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: 0.66.4 => 0.66.4 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

You shouldn’t use nvm because node_modules/react-native/scripts/find-node.sh file in old React Native can’t find path to node. Removing nvm can resolve your problem. Source: stackoverflow.com/questions/66742033/phasescriptexecution-cp-user-error-in-react-native

Thanks for the link. However, I still have the same error after removing nvm. The environment now:

TERM_PROGRAM=Apple_Terminal
TERM=xterm-256color
SHELL=/bin/bash
TMPDIR=/var/folders/84/85yg3v756w90md_90mkspt3d0j0qsw/T/
TERM_PROGRAM_VERSION=445
ANDROID_SDK_ROOT=/Users/zhongs/Library/Android/sdk
TERM_SESSION_ID=40548996-F6D9-4605-A022-71113EF8D6A4
USER=zhongs
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.aO9ZNPaQ7T/Listeners
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/zhongs/Library/Android/sdk/emulator:/Users/zhongs/Library/Android/sdk/platform-tools
LaunchInstanceID=895054D2-83C0-4384-B00B-B97140DD67DE
__CFBundleIdentifier=com.apple.Terminal
PWD=/xxxxx/reactnative-attention-app-main
XPC_FLAGS=0x0
XPC_SERVICE_NAME=0
HOME=/Users/xx
SHLVL=1
LOGNAME=xx
LC_CTYPE=UTF-8
SECURITYSESSIONID=186a3
_=/usr/bin/env

Some supplementary information: my macbook is not M1; it is 2.8 GHz Quad-Core Intel Core i7.

I can run project you mention without any problem. I suggest you check where node is by running command where node. The path should be /usr/local/bin/node or inside homebrew folder. If you have time, try my project, see if it throw same error or not.

I tried to follow the guideline for creating a new project: https://reactnative.dev/docs/environment-setup and got the error in this post again. So I guess there were some fundamental setup issues. I found this post: https://stackoverflow.com/questions/66742033/phasescriptexecution-cp-user-error-in-react-native and discovered the nvm installed by homebrew that I missed out in the removing process.

So I did the following and finally move on from this error and the app runs 😃. Many thanks!

xx:xx zhongs$ echo $(brew --prefix nvm)
/usr/local/opt/nvm
xx:xx zhongs$ brew uninstall nvm
Uninstalling /usr/local/Cellar/nvm/0.39.1_1... (9 files, 184.1KB)

Excellent solution ever 👌, I have tried lots of solution like setup “symlink” etc… but after two days continues r&d I found your solution and within 5-min I removed “nvm” from my mac system and install node alone and it’s work like a charm. Thank you 🙂

RN Version: 67.5 Node Version: 16.16.0 Mac System: Intel i3 xCode Version: 14.3.1

You shouldn’t use nvm because node_modules/react-native/scripts/find-node.sh file in old React Native can’t find path to node. Removing nvm can resolve your problem.

Source: https://stackoverflow.com/questions/66742033/phasescriptexecution-cp-user-error-in-react-native