-
-
Notifications
You must be signed in to change notification settings - Fork 224
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
Supports NVM in sentry-cli.js when build from XCode (React Native) - node no such file or directory #421
Comments
looks related: getsentry/sentry-react-native#484 commits: facebook/react-native@ce25c54 |
Looks like this is still a temporary solution that works: run this in your terminal - no edits required to project.pbxproj n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local |
https://docs.sentry.io/platforms/react-native/manual-setup/#using-node-with-nvm-or-notion |
@ManAnRuck what's the exact problem on CI you're running into? |
It appears that the "no such file or directory" error is coming from the sentry-cli script, as it is a javascript script, and also runs with node:
The error is actually coming from To confirm this, I changed this line of the build phase script :
To
Which should just print the help page of the command. I still see the error:
So the problem is that the Why? This is because for each build phase script, XCode will create a wrapper shell script and run it with a preset environment. To see the the wrapper script, go to XCode's report navigator after the build fails: There are two notable things about this output. First, the Second is this: After setting up a bunch of variables via
The shell that runs the script is ran in non-interactive mode, which typically means it won't read the "profile" files, including the call to initialize nvm. I don't know if this is the best solution, but one way to fix this is to initialize nvm in the build phase itself and then use it to set the node version to use:
Be sure to include the snippet in both Sentry build phases that call out to Update: I was curious as to why this doesn't affect the |
@export-mike would you be open to a PR to add nvm support to the sentry build phases? It would probably require a similar approach to what the react native team did, and would need to be wrapped in a shell script. |
Not really I don't think this is an issue for me anymore. @twelve17 this was 2 years ago |
@export-mike This indeed is an old issue, but it is still reproducible. Are you sure it's not an issue for you because you've done the temporary workaround of copying node to /usr/local? |
This is indeed still an issue |
really.. i can not fathom why the react-native team opt'd to be o proscriptive about the node version manager tooling . simply could of instead |
Is it really proscriptive? From the time the script was revived, it looked not just for It doesn't seem like the script is only allowing node to be ran from those version managers.
That would be a super nice solution for this project! On Facebook's side, I can see how adding a few popular options out of the box might save some headaches internally and externally. |
Inspired by @twelve17 and the find-node.sh script in React Native, I created a wrapper script for #!/usr/bin/env bash
# I don't expect this file to get used often! nvm has been added to the path
# and in most cases will be accessed directly. I'm just adding this file
# because the React Native Sentry package doesn't seem to handle nvm very
# well. It expects /usr/local/bin/node to be a valid executable and I want
# to make sure that executable handles .nvmrc files.
#
# https://github.com/getsentry/sentry-cli/issues/421
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
nvm use
exec node "$@" |
2021, still an issue |
Because of this issue, I chose to ditch the NVM in CI environment 2 years ago. I just stick to normal node installation since it's the most natural way to use node anyway. Haven't looked back since. |
Technically you have looked back if you’re here again ;) |
Thanks, @twelve17! By the way, I didn't get the "initialize nvm in the build phase" part from your instruction, please. So, where should I put your script in Xcode? |
Closing the issue, as it seems like the original issue has been partially resolved or there is a working solution. I'd prefer someone to create a new issue with a fresh description if it's still an issue. |
thanks man! it really helps! |
Reporting from 2022. Still an issue |
We're just going to move to using ASDF as it's the superior choice to any other specific language engine manager and is based on shims so not affected by problems that nvm has. |
Thanks for saving my time. For me, it can simplify to this n=$(which node);sudo cp -r $n /usr/local |
Dependencies
Currently, the sentry wizard made following change to
ProjectName.xcodeproj/project.pbxproj
This breaks RN apps with RVM with following error
The reason is
scripts/react-native-xcode.sh
can leveragenvm
node executable in their script but thesentry-cli
script didn'tThe fix was to copy the NVM handling part inside
scripts/react-native-xcode.sh
to build script to fix the above error.The text was updated successfully, but these errors were encountered: