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

Created on 1 Jul 2020  路  18Comments  路  Source: getsentry/sentry-react-native

OS:

  • [ ] Windows
  • [X] MacOS
  • [ ] Linux

Platform:

  • [X] iOS
  • [ ] Android

SDK:

  • [X] @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
  • [X] No

Are you using sentry.io or on-premise?

  • [X] sentry.io (SaaS)
  • [ ] on-premise

Configuration:

(@sentry/react-native)

Sentry.init({
  dsn: 'https://[email protected]/...'
});

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.

Most helpful comment

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

```# 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"

$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"
```

All 18 comments

@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",

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

@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 =>
```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

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

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

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

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

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

@karlludwigweise
build phases part of Xcode.

Screenshot 2020-07-02 at 17 51 50

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 馃檹

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

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

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

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: https://github.com/getsentry/sentry-react-native/issues/141

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

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

```# 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"

$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"
```

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

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

This is made my xcode see the node.

xcode 12
[email protected]
sentry/[email protected]

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!

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

This is made my xcode see the node.

Very good and clean solution. Worked

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 
Was this page helpful?
0 / 5 - 0 ratings