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

RN 0.66.5 + RN CLI: PhaseScriptExecution error (not with Xcode) #15

Closed
leotm opened this issue Mar 7, 2023 · 2 comments
Closed

RN 0.66.5 + RN CLI: PhaseScriptExecution error (not with Xcode) #15

leotm opened this issue Mar 7, 2023 · 2 comments
Labels
error build/run time blocker iOS

Comments

@leotm
Copy link
Member

leotm commented Mar 7, 2023

Follow-up to


From npx react-native@0.66.5 init RN0665 --version 0.66.5

yarn start --reset-cache

yarn ios

nvm is not compatible with the "PREFIX" environment variable: currently set to "/usr/local"
Run `unset PREFIX` to unset it.
Command PhaseScriptExecution failed with a nonzero exit code

The build error is now happening consistently for fresh RN projects, with unset PREFIX to no avail

Likely related to nvm from metamask-mobile setup (no other node manager in use)
nb: also running react-native+0.66.5.patch

If unable to figure soon, stick to Xcode (14.2 stable) for now i.e. not a blocker

nvm --version # 0.39.3
which nvm # nvm function definition: https://pastebin.com/CwvhKUN0
node --version # v14.21.3
which node # /opt/homebrew/opt/node@14/bin/node

echo $PATH

/opt/homebrew/opt/node@14/bin:/Users/leo/.rbenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/leo/Library/Android/sdk/emulator:/Users/leo/Library/Android/sdk/tools:/Users/leo/Library/Android/sdk/tools/bin:/Users/leo/Library/Android/sdk/platform-tools

@leotm
Copy link
Member Author

leotm commented Mar 7, 2023

This is likely fine with Xcode since

https://github.com/facebook/react-native/blob/0.66-stable/scripts/react-native-xcode.sh#L84 is calling

# Find path to Node
# shellcheck source=/dev/null
source "$REACT_NATIVE_DIR/scripts/find-node.sh"

# check and assign NODE_BINARY env
# shellcheck source=/dev/null
source "$REACT_NATIVE_DIR/scripts/node-binary.sh"

# ...

"$NODE_BINARY" $NODE_ARGS "$CLI_PATH" $BUNDLE_COMMAND \
  $CONFIG_ARG \
  --entry-file "$ENTRY_FILE" \
  --platform "$BUNDLE_PLATFORM" \
  --dev $DEV \
  --reset-cache \
  --bundle-output "$BUNDLE_FILE" \
  --assets-dest "$DEST" \
  $EXTRA_ARGS \
  $EXTRA_PACKAGER_ARGS

# ...

Different to our RN CLI

https://github.com/facebook/react-native/blob/0.66-stable/scripts/find-node.sh

#!/bin/bash
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

set -e

# Support Homebrew on M1
HOMEBREW_M1_BIN=/opt/homebrew/bin
if [[ -d $HOMEBREW_M1_BIN && ! $PATH =~ $HOMEBREW_M1_BIN ]]; then
  export PATH="$HOMEBREW_M1_BIN:$PATH"
fi

# Define NVM_DIR and source the nvm.sh setup script
[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"

if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
  # shellcheck source=/dev/null
  . "$HOME/.nvm/nvm.sh"
elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
  # shellcheck source=/dev/null
  . "$(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 -)"
elif [[ -x "$(command -v brew)" && -x "$(brew --prefix nodenv)/bin/nodenv" ]]; then
  eval "$("$(brew --prefix nodenv)/bin/nodenv" init -)"
fi

# Set up the ndenv of anyenv if preset
if [[ ! -x node && -d ${HOME}/.anyenv/bin ]]; then
  export PATH=${HOME}/.anyenv/bin:${PATH}
  if [[ "$(anyenv envs | grep -c ndenv )" -eq 1 ]]; then
    eval "$(anyenv init -)"
  fi
fi

https://github.com/facebook/react-native/blob/0.66-stable/scripts/node-binary.sh

#!/bin/bash
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

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

nodejs_not_found()
{
  echo "error: Can't find the '$NODE_BINARY' binary to build the React Native bundle. " \
       "If you have a non-standard Node.js installation, select your project in Xcode, find " \
       "'Build Phases' - 'Bundle React Native code and images' and change NODE_BINARY to an " \
       "absolute path to your node executable. You can find it by invoking 'which node' in the terminal." >&2
  exit 2
}

type "$NODE_BINARY" >/dev/null 2>&1 || nodejs_not_found

@leotm
Copy link
Member Author

leotm commented Mar 7, 2023

nvm unalias default 🎉 until find a better solution compatible with nvm and other node version managers

Screenshot 2023-03-06 at 19 28 16

@leotm leotm closed this as completed Mar 7, 2023
@leotm
Copy link
Member Author

leotm commented Mar 7, 2023

@leotm leotm added the iOS label Mar 12, 2023
@leotm leotm changed the title RN 0.66.5 + RN CLI + iOS: PhaseScriptExecution error (not with Xcode) RN 0.66.5 + RN CLI: PhaseScriptExecution error (not with Xcode) Mar 12, 2023
@leotm leotm added the error build/run time blocker label Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error build/run time blocker iOS
Projects
None yet
Development

No branches or pull requests

1 participant