getsentry / sentry-react-native

Official Sentry SDK for React-Native
https://sentry.io
MIT License
1.53k stars 321 forks source link

Upload debug symbols to Sentry step fails when node binary not at /usr/bin/node #3798

Closed taylorkline closed 1 week ago

taylorkline commented 2 weeks ago

OS:

Platform:

SDK:

SDK version:

  - RNSentry (5.22.0):
    - hermes-engine
    - React-Core
    - React-hermes
    - Sentry/HybridSDK (= 8.24.0)

react-native version: 0.73.8

Are you using Expo?

Are you using sentry.io or on-premise?

If you are using sentry.io, please post a link to your issue so we can take a look:

N/A

Configuration:

Bundle React Native Code and Images:

set -e

WITH_ENVIRONMENT="../../../node_modules/react-native/scripts/xcode/with-environment.sh"
REACT_NATIVE_XCODE="../../../node_modules/react-native/scripts/react-native-xcode.sh"
SENTRY_XCODE="../../../node_modules/@sentry/react-native/scripts/sentry-xcode.sh"
BUNDLE_REACT_NATIVE="/bin/sh $SENTRY_XCODE $REACT_NATIVE_XCODE"
/bin/sh -c "$WITH_ENVIRONMENT \"$BUNDLE_REACT_NATIVE\""

Upload debug symbols to Sentry:

export SENTRY_PROPERTIES=sentry.properties

[[ $SENTRY_INCLUDE_NATIVE_SOURCES == "true" ]] && INCLUDE_SOURCES_FLAG="--include-sources" || INCLUDE_SOURCES_FLAG=""
SENTRY_CLI="../../../node_modules/@sentry/cli/bin/sentry-cli"
$SENTRY_CLI --log-level=debug debug-files upload "$INCLUDE_SOURCES_FLAG" "$DWARF_DSYM_FOLDER_PATH"

I have the following issue:

The build stage "Upload Debug Symbols to Sentry" fails with

Steps to reproduce:

Install node with something like fnm and configure correctly.

Observe that /usr/bin/env node displays "Welcome to Node.js v...."

Observe that, because of .xcode.env.local, the step "Bundle React Native code and images" succeeds fine and outputs "Node found at:..."

Observe that, because of the shebang in @sentry/cli/bin/sentry-cli, running the script immediately errors with "env: node: No such file or directory".

Observe that when node is symlinked in /usr/local/bin/node, the step succeeds fine.

Actual result:

"Upload Debug Symbols to Sentry" should find and use node just like "Bundle React Native code and images"

Expected result:

"Upload Debug Symbols to Sentry" requires node to be in the default PATH because of the #!/usr/bin/env node shebang

krystofwoldrich commented 1 week ago

Hi, thank you for the message, you can replace the Upload Debug Symbols to Sentry shell script with the following code.

/bin/sh ../../scripts/sentry-xcode-debug-files.sh

Let us know if this solution helped you, if not feel free to comment with more details and we can reopen the issue.

taylorkline commented 1 week ago

Hi, thank you for the message, you can replace the Upload Debug Symbols to Sentry shell script with the following code.

/bin/sh ../../scripts/sentry-xcode-debug-files.sh

Let us know if this solution helped you, if not feel free to comment with more details and we can reopen the issue.

@krystofwoldrich no dice, after changing the command to /bin/sh ../../../node_modules/@sentry/react-native/scripts/sentry-xcode-debug-files.sh

+ '[' -z '' ']'
+ WITH_ENVIRONMENT=../node_modules/react-native/scripts/xcode/with-environment.sh
+ '[' -f ../node_modules/react-native/scripts/xcode/with-environment.sh ']'
+ set -e
+ LOCAL_NODE_BINARY=node
+ '[' -z '' ']'
+ export SENTRY_PROPERTIES=sentry.properties
+ SENTRY_PROPERTIES=sentry.properties
+ '[' -z '' ']'
++ node --print 'require('\''path'\'').dirname(require.resolve('\''@sentry/cli/package.json'\''))'
../../../node_modules/@sentry/react-native/scripts/sentry-xcode-debug-files.sh: line 22: node: command not found
+ SENTRY_CLI_PACKAGE_PATH=
Command PhaseScriptExecution failed with a nonzero exit code

The "Bundle React Code and Images" step still has no problem.

Node found at: /Users/taylor/node-18
+ LOCAL_NODE_BINARY=/Users/taylor/node-18
+ '[' -z '' ']'
taylorkline commented 1 week ago

@krystofwoldrich following the way "Bundle React Code and Images" works, I made "Upload Debug Symbols to Sentry" work as follows:

WITH_ENVIRONMENT="../../../node_modules/react-native/scripts/xcode/with-environment.sh"

/bin/sh -c "$WITH_ENVIRONMENT ../../../node_modules/@sentry/react-native/scripts/sentry-xcode-debug-files.sh"

This worked fine. What do you think?