Skip to content

with-environment.sh does not work properly with .xcode.env #42804

Closed

Description

@msageryd

Description

The purpuse of xcode.env is to export your own node executable path without messing with the build script.

This does not work properly when using NVM, due to with-environment.sh trying to call node -v prematurely.

with-environment.sh crashes at line 16 because there is no node executable to be found before nvm.sh is sourced.

# Start with a default
NODE_BINARY=$(command -v node).  # this is line 16

If xcode.env is used correctly with NVM, nvm.sh should be sourced in this file before the call to node -v. Unfortunately, xcode.env itself is sourced after line 16 in with-environment.sh, which is too late. Line 16 isn't even needed since the same call is performed in xcode.env.

Workaround:
Remove line 16 in with-environment.sh.

# Start with a default
#NODE_BINARY=$(command -v node)

I suggest that the premature call to node from within with-environment is removed so the nicely separated xcode.env can do it's thing.

Steps to reproduce

  1. Install NVM
  2. Update xcode.env as per the commented instructions
  3. Build from XCode

React Native Version

0.73.3

Affected Platforms

Build - MacOS

Output of npx react-native info

not needed

Stacktrace or Logs

+++ command -v node
++ NODE_BINARY=
Command PhaseScriptExecution failed with a nonzero exit code

Reproducer

nope

Screenshots and Videos

No response

Activity

  1. added
    Needs: Repro
    on Feb 2, 2024
  2. github-actions commented on Feb 2, 2024

    @github-actions
    ⚠️ Missing Reproducible Example
    ℹ️ We could not detect a reproducible example in your issue report. Please provide either:
    • If your bug is UI related: a Snack
    • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.
  3. msageryd commented on Feb 2, 2024

    @msageryd
    Author

    Will this issue be disregarded because I don't have a "Reproducible Example"?
    I have exactly pinpointed a problem at line 16 in a bash file. What more can I do?

  4. added
    Needs: Attention
    and removed on Feb 2, 2024
  5. cortinico commented on Feb 2, 2024

    @cortinico
    Contributor

    Already fixed by:

    If you wish to have this backported to 0.73, please comment on the relevant discussion on https://github.com/reactwg/react-native-releases/

  6. added
    Resolution: Fixed
    and removed
    Needs: Repro
    Needs: Attention
    on Feb 2, 2024
  7. msageryd commented on Feb 2, 2024

    @msageryd
    Author

    Great thanks!
    I searched in issues, but didn't find any on this. Hence my post.

  8. msageryd commented on Feb 6, 2024

    @msageryd
    Author

    I didn't get a fixed with-environment.sh with my upgrade to 0.73.4. Was this patch omitted when picking patches for 0.73.4?

    No big deal for me. I just want to understand how releases and patch-picking works.

  9. cortinico commented on Feb 6, 2024

    @cortinico
    Contributor

    This pick in only on main.

    If you wish to have this backported to 0.73, please comment on the relevant discussion on reactwg/react-native-releases

    As I said, if you want this pick to be picked on the future 0.73.x, head over to https://github.com/reactwg/react-native-releases/ and comment on the relevant conversation

  10. msageryd commented on Feb 6, 2024

    @msageryd
    Author

    Ah, ok.
    I thought you meant backported to 0.73.3 and it would be automatically picked for the next release. I think this should be picked ASAP in order to minimize the hazzle for people encountering this. I'll leave a comment in the release-conversation.

  11. bheftyes commented on Mar 18, 2024

    @bheftyes

    @msageryd what is your .xcode.env looking like? I can't seem to be able to get nvm to work.

  12. msageryd commented on Mar 18, 2024

    @msageryd
    Author

    @bheftyes I haven't revisited this since I solved the problem brute-force. Currently I have hardcoded my Node path.

    export NODE_BINARY=/Users/michaelsageryd/.nvm/versions/node/v18.19.0/bin/node
    
  13. zhouhao27 commented on Dec 19, 2024

    @zhouhao27

    I still got this issue in 0.76.1. My Xcode version is 16.1. Any idea?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution: Fixed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions