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

XCode Build Fails: PhaseScriptExecution failed with a nonzero exit code #948

Closed
5 of 11 tasks
karlludwigweise opened this issue Jul 1, 2020 · 26 comments
Closed
5 of 11 tasks

Comments

@karlludwigweise
Copy link

OS:

  • Windows
  • MacOS
  • Linux

Platform:

  • iOS
  • Android

SDK:

  • @sentry/react-native (>= 1.0.0)
  • react-native-sentry (<= 0.43.2)

SDK version: 15.0.0

react-native version: 0.62.2

Are you using Expo?

  • Yes
  • No

Are you using sentry.io or on-premise?

  • sentry.io (SaaS)
  • on-premise

Configuration:

(@sentry/react-native)

Sentry.init({
  dsn: 'https://...@sentry.io/...'
});

I have following issue:

Building an iOS App Sentry fails with: env: node: No such file or directory Command PhaseScriptExecution failed with a nonzero exit code

Executing /bin/sh -c /Users/{USERNAME}/Library/Developer/Xcode/DerivedData/{ID}/Build/Intermediates.noindex/{APP}.build/Release-iphoneos/{APP}.build/Script-00DD1BFF1BD5951E006B06BC.sh in on the console will throw the following error: line 5: ../node_modules/@sentry/cli/bin/sentry-cli: No such file or directory

Steps to reproduce:

Following the setup on https://docs.sentry.io/platforms/react-native/

  • Step 1: yarn add @sentry/react-native
  • Step 2: yarn sentry-wizard -i reactNative -p ios android
  • Step 3: cd ios && pod install
  • Setp 4: Setting up JS Error handling

Connecting the SDK to Sentry and verifying it in DEV Mode works fine.

In XCode:

  • Step 5: Clean Build Folder
  • Step 6: Build Configuration Release
  • Step 7: Removing localhost from App Transport Security Settings
  • Step 8: Run Build

Actual result:

Build fails env: node: No such file or directory Command PhaseScriptExecution failed with a nonzero exit code

Expected result:

Build runs successfully.

@sprotymo
Copy link

sprotymo commented Jul 2, 2020

@karlludwigweise do You have any solutions?

I have this errors to.
My env:

System:
OS: macOS 10.15.5
Binaries:
Node: 12.16.1 - ~/.nvm/versions/node/v12.16.1/bin/node
Yarn: 1.22.4 - ~/.nvm/versions/node/v12.16.1/bin/yarn
npm: 6.13.4 - ~/.nvm/versions/node/v12.16.1/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.9.3 - /usr/local/bin/pod
Homebrew: 2.4.2 - /usr/local/bin/brew
pip3: 10.0.1 - /usr/local/bin/pip3
RubyGems: 3.0.3 - /usr/bin/gem
SDKs:
iOS SDK:
Platforms: iOS 13.5, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
IDEs:
Xcode: 11.5/11E608c - /usr/bin/xcodebuild
Languages:
Bash: 3.2.57 - /bin/bash
Java: 1.8.0_171 - /usr/bin/javac
Ruby: 2.6.3 - /usr/bin/ruby

REACT_NATIVE:
"react-native": "0.62.2",
"@sentry/react-native": "^1.5.0",

@karlludwigweise
Copy link
Author

@sprotymo sadly no. There is Issue #108, but none of the work arounds work for me.

@sprotymo
Copy link

sprotymo commented Jul 2, 2020

@karlludwigweise
I found fixes for my issue.
watchman watch-del-all && rm -rf node_modules/ && rm -rf /tmp/metro-bundler-cache-* && rm -rf /tmp/haste-map-react-native-packager-* && yarn && cd ios && rm -rf Pods && rm -rf Podfile.lock && pod install && cd ../

remove derivedData, clean build.

build phases
Upload Debug Symbols to Sentry =>


# Setup nvm and set node
[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"

if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
. "$HOME/.nvm/nvm.sh"
elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
. "$(brew --prefix nvm)/nvm.sh"
fi

[ -z "$NODE_BINARY" ] && export NODE_BINARY="node"

$NODE_BINARY ../node_modules/@sentry/cli/bin/sentry-cli upload-dsym

Bundle React Native code and images =>


# Setup nvm and set node
[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"

if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
. "$HOME/.nvm/nvm.sh"
elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
. "$(brew --prefix nvm)/nvm.sh"
fi

[ -z "$NODE_BINARY" ] && export NODE_BINARY="node"
n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local


../node_modules/@sentry/cli/bin/sentry-cli react-native xcode
../node_modules/react-native/scripts/react-native-xcode.sh

I hope it helps You to.

@karlludwigweise
Copy link
Author

@sprotymo what's the build phases part? Is that your .zshrc?

@sprotymo
Copy link

sprotymo commented Jul 2, 2020

@karlludwigweise
build phases part of Xcode.

Screenshot 2020-07-02 at 17 51 50

@karlludwigweise
Copy link
Author

Well, that works like a charm. Where did you get that info?

I guess it is a problem when using Node with a version manager. Thanks 🙏

@jennmueng
Copy link
Member

Hi guys, looks like everything is solved, are we good to close this?

@sprotymo
Copy link

sprotymo commented Jul 3, 2020

Well, that works like a charm. Where did you get that info?

found by chance, in the link to the official documentation and possible problems with nvm

@karlludwigweise
Copy link
Author

I would throw in a missing documentation on https://docs.sentry.io/platforms/react-native/ but otherwise I'm good with closing it. 👍

@karlludwigweise
Copy link
Author

karlludwigweise commented Jul 5, 2020

Getting back to it a few days later: This is not a sufficient fix for me, because it destroyes my development build on the simulator.

EDIT:
Something else must have been wrong with my setup at the time. The solutions works properly in Debug and Release Build Configuration.

If anyone is looking for the original info: #141

@andrekovac
Copy link

I am working on an ejected Expo App in the bare workflow and applied the first part of @sprotymo solution and it works! Thanks!

In build phases I changed the Upload Debug Symbols to Sentry script to match the one he describes. I also had the line export SENTRY_PROPERTIES=sentry.properties in my original script, so it eventually looked like this:

# Setup nvm and set node
[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"

if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
. "$HOME/.nvm/nvm.sh"
elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
. "$(brew --prefix nvm)/nvm.sh"
fi

[ -z "$NODE_BINARY" ] && export NODE_BINARY="node"

export SENTRY_PROPERTIES=sentry.properties
$NODE_BINARY ../node_modules/@sentry/cli/bin/sentry-cli upload-dsym

I don't have a Bundle React Native code and images script in build phases so I didn't add it.

@anubhavsahoo
Copy link

@sprotymo - this guys solution worked for me. though i didnt have to clean adn reinstall everything
I had to add the following scripts to the beginning of the Build Phase sections called

  1. Bundle react native code and images
  2. upload debug symbols to sentry
# Setup nvm and set node
[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"

if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
. "$HOME/.nvm/nvm.sh"
elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
. "$(brew --prefix nvm)/nvm.sh"
fi

[ -z "$NODE_BINARY" ] && export NODE_BINARY="node"

Note append the above to the beginning of those sections - before the existing script that must already be present in those sections.

I am guessing the issue is with using nvm. scripts added by sentry wizard are not able to locate node binaries when you use nvm

@andru1989
Copy link

I was using nvm and non of solutions worked for me

So looking in docs I found this solution: https://docs.sentry.io/clients/react-native/manual-setup/#using-node-with-nvm-or-notion

Basically I set the scripts like this

Bundle React Native code and images

export SENTRY_PROPERTIES=sentry.properties

# Setup nvm and set node
[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"

if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
. "$HOME/.nvm/nvm.sh"
elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
. "$(brew --prefix nvm)/nvm.sh"
fi

# Set up the nodenv node version manager if present
if [[ -x "$HOME/.nodenv/bin/nodenv" ]]; then
eval "$("$HOME/.nodenv/bin/nodenv" init -)"
fi

# Trying notion
if [ -z "$NODE_BINARY" ]; then
if [[ -s "$HOME/.notion/bin/node" ]]; then
export NODE_BINARY="$HOME/.notion/bin/node"
fi
fi

[ -z "$NODE_BINARY" ] && export NODE_BINARY="node"

$NODE_BINARY ../node_modules/@sentry/cli/bin/sentry-cli react-native xcode \
  ../node_modules/react-native/scripts/react-native-xcode.sh

Upload Debug Symbols to Sentry

# First set the path to sentry.properties
export SENTRY_PROPERTIES=sentry.properties

# Setup nvm and set node
[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"

if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
. "$HOME/.nvm/nvm.sh"
elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
. "$(brew --prefix nvm)/nvm.sh"
fi

# Set up the nodenv node version manager if present
if [[ -x "$HOME/.nodenv/bin/nodenv" ]]; then
eval "$("$HOME/.nodenv/bin/nodenv" init -)"
fi

# Trying notion
if [ -z "$NODE_BINARY" ]; then
if [[ -s "$HOME/.notion/bin/node" ]]; then
export NODE_BINARY="$HOME/.notion/bin/node"
fi
fi

[ -z "$NODE_BINARY" ] && export NODE_BINARY="node"

# Run sentry cli script to upload debug symbols
$NODE_BINARY ../node_modules/@sentry/cli/bin/sentry-cli upload-dif "$DWARF_DSYM_FOLDER_PATH"

@karlludwigweise
Copy link
Author

karlludwigweise commented Dec 4, 2020

@andru1989 thank you. I prefer this one over the solutions above, because it does not mess with device build via xcode.

@Duduzera1997
Copy link

sudo ln -s "$(which node)" /usr/local/bin/node

This is made my xcode see the node.

@dienp
Copy link

dienp commented Apr 5, 2021

xcode 12
react-native@0.6.32
sentry/react-native@2.4.0

Took a few hours to debug, finally got it working with the following scripts:

Bundle React Native code and images

cd $PROJECT_DIR/..

export SENTRY_PROPERTIES=ios/sentry.properties

# Setup nvm and set node
[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"

if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
. "$HOME/.nvm/nvm.sh"
elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
. "$(brew --prefix nvm)/nvm.sh"
fi

# Set up the nodenv node version manager if present
if [[ -x "$HOME/.nodenv/bin/nodenv" ]]; then
eval "$("$HOME/.nodenv/bin/nodenv" init -)"
fi

# Trying notion
if [ -z "$NODE_BINARY" ]; then
if [[ -s "$HOME/.notion/bin/node" ]]; then
export NODE_BINARY="$HOME/.notion/bin/node"
fi
fi

[ -z "$NODE_BINARY" ] && export NODE_BINARY="node"

$NODE_BINARY ./node_modules/@sentry/cli/bin/sentry-cli react-native xcode ./node_modules/react-native/scripts/react-native-xcode.sh

Upload Debug Symbols to Sentry

cd $PROJECT_DIR/..

export SENTRY_PROPERTIES=ios/sentry.properties

# Setup nvm and set node
[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"

if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
. "$HOME/.nvm/nvm.sh"
elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
. "$(brew --prefix nvm)/nvm.sh"
fi

# Set up the nodenv node version manager if present
if [[ -x "$HOME/.nodenv/bin/nodenv" ]]; then
eval "$("$HOME/.nodenv/bin/nodenv" init -)"
fi

# Trying notion
if [ -z "$NODE_BINARY" ]; then
if [[ -s "$HOME/.notion/bin/node" ]]; then
export NODE_BINARY="$HOME/.notion/bin/node"
fi
fi

[ -z "$NODE_BINARY" ] && export NODE_BINARY="node"
$NODE_BINARY ./node_modules/@sentry/cli/bin/sentry-cli upload-dsym

Hope these help guys!

@rogerkerse
Copy link

sudo ln -s "$(which node)" /usr/local/bin/node

This is made my xcode see the node.

Very good and clean solution. Worked

@roycehe
Copy link

roycehe commented Jun 15, 2021

Bundle React Native code and images

export SENTRY_PROPERTIES=sentry.properties
export EXTRA_PACKAGER_ARGS="--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map"
export NODE_BINARY=node
../node_modules/react-native/scripts/react-native-xcode.sh
../node_modules/@sentry/cli/bin/sentry-cli react-native xcode 

@ts-ign0re
Copy link

Hi folks!

Just replace this export NODE_BINARY=node on this export NODE_BINARY="$(which node)"

@sakshiigoyal
Copy link

sakshiigoyal commented Dec 16, 2021

Facing this same issue in my CLI.

The following build commands failed: PhaseScriptExecution Bundle\ React\ Native\ code\ and\ images /Users/runner/Library/Developer/Xcode/DerivedData/Project/Build/Intermediates.noindex/ArchiveIntermediates/Project/IntermediateBuildFilesPath/Project.build/Release-iphoneos/Project.build/Script-00DD1BFF1BD5951E006B06BC.sh (in target 'Project' from project 'Project') (1 failure) ##[error]Error: /usr/bin/xcodebuild failed with return code: 65

@tandonpushkar
Copy link

tandonpushkar commented Jan 8, 2022

This solution worked for me :
brew uninstall node
After that download node from official documentation https://nodejs.org/en/download/

@EdDevs2503
Copy link

sudo ln -s "$(which node)" /usr/local/bin/node

This is made my xcode see the node.

It worked for me. I am using Mac Mini with M1 chipset

@truongqt
Copy link

truongqt commented Apr 2, 2022

I renamed my project in Project Settings / PROJECT DETAILS on sentry, then I got this error. So I fixed my problem: undo rename the project in: Project Settings / PROJECT DETAILS. Hope this helps anyone.
Screen Shot 2022-04-02 at 22 24 20

@JeffPatricio
Copy link

sudo ln -s "$(which node)" /usr/local/bin/node

This is made my xcode see the node.

Best solution, it worked for me, thank you very much

@bwoodlt
Copy link

bwoodlt commented May 8, 2022

Worked for me

sudo ln -s "$(which node)" /usr/local/bin/node

This is made my xcode see the node.

Nice one man! Worked for me!

@marandaneto
Copy link
Contributor

@getsentry getsentry locked and limited conversation to collaborators May 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests