question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Command PhaseScriptExecution failed with a nonzero exit code

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:15

github_iconTop GitHub Comments

2reactions
sailinzcommented, Aug 24, 2022

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)
0reactions
pnthach95commented, Aug 24, 2022

Same as your. I use M1. Check out this solution https://stackoverflow.com/questions/55235825/error-failed-to-build-ios-project-we-ran-xcodebuild-command-but-it-exited-wit

If it don’t work, I’m out of solutions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Xcode 11 Command PhaseScriptExecut… - Apple Developer
When compiling, I keep getting this error: Command PhaseScriptExecution failed with a nonzero exit code. I tried in Xcode. Xcode > Preferences >...
Read more >
How to Fix Xcode Command PhaseScriptExecution failed with ...
The Xcode 11 “Command PhaseScriptExecution failed with a nonzero exit code” error message can be concerning for developers.
Read more >
Xcode 10.2.1 Command PhaseScriptExecution failed with a ...
How do I resolve " Command PhaseScriptExecution failed with a nonzero exit code " error when trying to archive project. And I am...
Read more >
Command PhaseScriptExecution failed with a nonzero exit code
Hello there, I have been struggling with configuring Apollo for a while now and can't solve the problem. I am currently stuck in...
Read more >
FIXED: Xcode Command PhaseScriptExecution Failed With A ...
The Xcode 11 error notice “Command PhaseScriptExecution failed with a nonzero exit code” can be problematic for developers.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found