Skip to content

Commit

Permalink
Fix: OSS builds can accidentally using coreutils cp (#44097)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #44097

There are two places where we use a feature specific to the system version of 'cp', the:

  -X    Do not copy Extended Attributes (EAs) or resource forks.

This feature isn't available in GNU's cp, which is commonly installed on macOS using:

  brew install coreutils && brew link coreutils

We can avoid the problem alltogether by being specific about the path of the system cp.

Changelog: [General][Fixed] don't break script phase and codegen when coreutils installed on macOS

Reviewed By: cipolleschi

Differential Revision: D56143216

fbshipit-source-id: f1c1ef9ea2f01614d6d89c4e9eedf43113deb80c
  • Loading branch information
blakef authored and facebook-github-bot committed Apr 17, 2024
1 parent 1d26907 commit e079953
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions packages/react-native-codegen/scripts/oss/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ EDEN_SAFE_MV="mv"
if [ -x "$(command -v eden)" ]; then
pushd "$THIS_DIR"

# Detect if we are in an EdenFS checkout
# Detect if we are in an EdenFS checkout, but be sure to use /bin/cp
# incase users have GNU coreutils installed which is incompatible with -X
if [[ "$OSTYPE" == "darwin"* ]] && eden info; then
EDEN_SAFE_MV="cp -R -X"
EDEN_SAFE_MV="/bin/cp -R -X"
fi

popd >/dev/null
Expand Down Expand Up @@ -60,7 +61,7 @@ else
if [ "$OSTYPE" = "msys" ] || [ "$OSTYPE" = "cygwin" ]; then
tar cf - --exclude='*.lock' "$CODEGEN_DIR" | (cd "$TMP_DIR" && tar xvf - );
else
cp -R "$CODEGEN_DIR/." "$TMP_DIR";
/bin/cp -R "$CODEGEN_DIR/." "$TMP_DIR";
fi

pushd "$TMP_DIR" >/dev/null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ moveOutputs () {
mkdir -p "$RCT_SCRIPT_OUTPUT_DIR"

# Copy all output to output_dir
cp -R -X "$TEMP_OUTPUT_DIR/." "$RCT_SCRIPT_OUTPUT_DIR" || exit 1
/bin/cp -R -X "$TEMP_OUTPUT_DIR/." "$RCT_SCRIPT_OUTPUT_DIR" || exit 1
echo "$LIBRARY_NAME output has been written to $RCT_SCRIPT_OUTPUT_DIR:" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1
ls -1 "$RCT_SCRIPT_OUTPUT_DIR" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1
}
Expand Down

1 comment on commit e079953

@MAsadIlyasNajum
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible Solutions for React Native Upgrade Issue

If you're encountering issues after upgrading React Native from version 0.72.x to 0.73.x or 0.74.x, please consider the following solutions:

Quick Solution: Remove the .xcode.env.local file located at app/ios/.xcode.env.local and attempt to run the project again. The reason for this is that the React Native upgrade helper does not include this file, which might be causing conflicts.

Additional Information: A fix for this issue is mentioned in this GitHub thread. The fix is expected to be included in React Native version 0.74.4, which should be available soon.

I hope these steps help resolve the issue.

Please sign in to comment.