sentry-react-native: XCode Build Fails: PhaseScriptExecution failed with a nonzero exit code

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.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 12
  • Comments: 26 (2 by maintainers)

Most upvoted comments

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

This is made my xcode see the node.

@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.

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"

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

This is made my xcode see the node.

Very good and clean solution. Worked

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.

@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

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

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

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!

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

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

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