mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
0d82b402aa
Summary: When the node version could not be found there is an error message shown to help what can be done to fix this issue (for example in the error logs in xcode) The problem was that the backtick symbol is interpreted as running commands in terminals so the parts that were in backticks were run and the error message was printed incompletely. Also there were other errors added (.xcode.env command not found, for example) which makes it harder to understand what is going on. In bash / zsh single quotes does not expand commands and variables unlike double quotes which does this. ## Changelog [IOS] [FIXED] - Fix missing node error message not printed correctly when deprecated `find-node-for-xcode.sh` is used. Pull Request resolved: https://github.com/facebook/react-native/pull/36140 Test Plan: I just ran the xcode build again after updating it manually in the node_modules folder. The log output changed from this ``` [Warning] You need to configure your node path in the environment. You can set it up quickly by running: echo 'export NODE_BINARY=/Users/uloco/Library/Caches/fnm_multishells/78434_1676301546457/bin/node' > .xcode.env in the ios folder. This is needed by React Native to work correctly. We fallback to the DEPRECATED behavior of finding . This will be REMOVED in a future version. You can read more about this here: https://reactnative.dev/docs/environment-setup#optional-configuring-your-environment ``` to this ``` [Warning] You need to configure your node path in the `".xcode.env" file` environment. You can set it up quickly by running: `echo export NODE_BINARY=$(command -v node) > .xcode.env` in the ios folder. This is needed by React Native to work correctly. We fallback to the DEPRECATED behavior of finding `node`. This will be REMOVED in a future version. You can read more about this here: https://reactnative.dev/docs/environment-setup#optional-configuring-your-environment ``` Reviewed By: cortinico, cipolleschi Differential Revision: D43258623 Pulled By: rshest fbshipit-source-id: 7db0d983b204e59504666686be78311c4c2fb993
48 lines
1.7 KiB
Bash
Executable File
48 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
||
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
||
#
|
||
# This source code is licensed under the MIT license found in the
|
||
# LICENSE file in the root directory of this source tree.
|
||
|
||
# This script is used to source in Xcode the environment settings required to run properly.
|
||
# The script first sources the base `.xcode.env` file.
|
||
# Then it sources the `.xcode.env.local` file if present, to override some local config
|
||
# Finally, it will execute the command passed i input if any.
|
||
#
|
||
# USAGE:
|
||
# ./with-environment.sh command
|
||
|
||
# Start with a default
|
||
NODE_BINARY=$(command -v node)
|
||
export NODE_BINARY
|
||
|
||
# Override the default with the global environment
|
||
ENV_PATH="$PODS_ROOT/../.xcode.env"
|
||
if [ -f "$ENV_PATH" ]; then
|
||
source "$ENV_PATH"
|
||
fi
|
||
|
||
# Override the global with the local environment
|
||
LOCAL_ENV_PATH="${ENV_PATH}.local"
|
||
if [ -f "$LOCAL_ENV_PATH" ]; then
|
||
source "$LOCAL_ENV_PATH"
|
||
fi
|
||
|
||
# Check whether NODE_BINARY has been properly set, otherwise help the users with a meaningful error.
|
||
if [ -n "$NODE_BINARY" ]; then
|
||
echo "Node found at: ${NODE_BINARY}"
|
||
else
|
||
echo '[Warning] You need to configure your node path in the `".xcode.env" file` environment. ' \
|
||
'You can set it up quickly by running: ' \
|
||
'`echo export NODE_BINARY=$(command -v node) > .xcode.env` ' \
|
||
'in the ios folder. This is needed by React Native to work correctly. ' \
|
||
'We fallback to the DEPRECATED behavior of finding `node`. This will be REMOVED in a future version. ' \
|
||
'You can read more about this here: https://reactnative.dev/docs/environment-setup#optional-configuring-your-environment' >&2
|
||
source "${REACT_NATIVE_PATH}/scripts/find-node-for-xcode.sh"
|
||
fi
|
||
|
||
# Execute argument, if present
|
||
if [ -n "$1" ]; then
|
||
$1
|
||
fi
|