react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Fix compatibility issue with 'cp' command in shell script.

Open sebastiancarlos opened this issue 1 year ago • 4 comments

Summary:

This change addresses a compatibility issue arising from the use of the macOS-specific -X flag in the cp command withing a shell script called during the npm run ios command.

The -X flag prevents the copying of Extended Attributes and resource forks, which indeed prevents possible issues on macOS. However the flag is not supported by GNU's cp, commonly installed via homebrew on macOS systems, and usually added to the user's PATH.

This fix basically does a feature test to figure out if the -X flag is available, and only uses it is the test is positive.

The intended behavior of not copying Extended Attributes and resources forks is still preserved in the script even if GNU's cp is in the path, as GNU's cp doesn't copy these by default.

In short, the script will behave correctly regardless of the cp version installed, but the script will now be more POSIX compatible.

The fix helps prevent unnecessary debugging time as, in my experience, the source of this error is not always displayed in the output of npm run ios.

As mentioned in:

  • https://github.com/facebook/react-native/issues/42112#issuecomment-1922990774
  • https://github.com/facebook/react-native/issues/39734#issuecomment-1932644315

Relevant Documentation

Changelog:

[IOS] [FIXED] - Fix compatibility issue with 'cp' command in shell script.

Test Plan:

# with GNU's cp in path
npm run ios
# observe build passing (this is the fix)

# remove GNU's cp from path
npm run ios
# observe build passing (no regression)

sebastiancarlos avatar Feb 18 '24 17:02 sebastiancarlos

Hi @sebastiancarlos!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

facebook-github-bot avatar Feb 18 '24 17:02 facebook-github-bot

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 17,885,653 +4,104
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 21,240,052 +21
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: 8ff05b5a18db85ab699323d1745a5f17cdc8bf6c Branch: main

analysis-bot avatar Feb 18 '24 17:02 analysis-bot

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

facebook-github-bot avatar Feb 18 '24 18:02 facebook-github-bot

Is there a tmp fix for that?

felixmueller-cnnctvstn avatar Feb 19 '24 10:02 felixmueller-cnnctvstn

Looks like this was done already: https://github.com/blakef/react-native/commit/e70076a23409b9a4920e4c6b2d7d3f840e738cc5

sebastiancarlos avatar May 14 '24 18:05 sebastiancarlos