Skip to content

Creation of .xcode.env.local points to a temp file for node when run using yarn #43285

Closed
@lindboe

Description

@lindboe

Description

Who this affects: Anyone using a yarn alias to run pod install. This includes expo prebuild.

When using yarn to set up pods, Yarn generates temporary references to node and yarn executables that are not supposed to persist, but RN is capturing them and storing them in .xcode.env.local.

This will actually continue to work for most people, because the files in this temporary dir /var/folders/.../T should only be deleted after 3 days of not accessing them. Source: https://magnusviri.com/what-is-var-folders.html. I took a long weekend and my project broke 😄

Workaround: Delete .xcode.env.local if it exists, and then run bundle exec pod install directly, not using yarn, or run npx expo prebuild if you're using a recent expo project that uses prebuild. This should generate the .xcode.env.local file correctly.

Note: I'm not sure why .xcode.env.local is being generated automatically in the first place. My projects run fine without it present. This is especially painful with Expo CNG, because I can't choose to skip generation of this file, it means I have to avoid using yarn for prebuild, or add a config plugin just to manage .xcode.env.local.

Steps to reproduce

  1. Have or create an RN app using yarn. Ensure there is no existing .xcode.env.local file:
    a. If this is a new project from template, say no to the cocoapods install when prompted. Run bundle install.
    b. If this was an existing project, delete the ios/.xcode.env.local file (it will be recreated by pod install).
  2. Add a yarn alias for pod install in package.json:
    "scripts": {
       "pod-install": "cd ios && bundle exec pod install"
       ...
    },
    
  3. Run the yarn alias: yarn pod-install. Note that ios/.xcode.env.local has been created, with a path to NODE_BINARY under /var/folders, like this: export NODE_BINARY=/var/folders/76/2f12v5nx7tq1vqbfptq455l00000gn/T/yarn--1709317581711-0.9959945438201141/node
  4. Try to build the app with yarn ios. The build will work because the temporary alias to node still exists. However, once the temp file is deleted, builds will start failing.
  5. Delete the temp file referenced in .xcode.env.local.

React Native Version

0.73.5.

Affected Platforms

Runtime - iOS, Build - MacOS

Output of npx react-native info

System:
  OS: macOS 14.3.1
  CPU: (8) arm64 Apple M1
  Memory: 73.97 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.9.0
    path: ~/.nvm/versions/node/v20.9.0/bin/node
  Yarn:
    version: 1.22.21
    path: ~/.nvm/versions/node/v20.9.0/bin/yarn
  npm:
    version: 10.1.0
    path: ~/.nvm/versions/node/v20.9.0/bin/npm
  Watchman:
    version: 2024.01.22.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods: Not Found
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - visionOS 1.0
      - watchOS 10.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.1 AI-231.9392.1.2311.11330709
  Xcode:
    version: 15.2/15C500b
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.10
    path: /Users/lizzi/.jenv/shims/javac
  Ruby:
    version: 2.6.10
    path: /Users/lizzi/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.5
    wanted: 0.73.5
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Stacktrace or Logs

The following build commands failed:
	PhaseScriptExecution [CP-User]\ [Hermes]\ Replace\ Hermes\ for\ the\ right\ configuration,\ if\ needed /Users/lizzi/Library/Developer/Xcode/DerivedData/TodoSharer-bpdgubyufiaiekcndqxujflhqusl/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/hermes-engine.build/Script-46EB2E0001C8A0.sh (in target 'hermes-engine' from project 'Pods')
(1 failure)

log file says this:
1099 Node found at: /var/folders/2d/_8p7fdvj1v13vkh7wyrbk14h0000gn/T/yarn--1707870956680-0.647996518200334/node
1100 /Users/lizzi/Library/Developer/Xcode/DerivedData/TodoSharer-bpdgubyufiaiekcndqxujflhqusl/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/hermes-engine.build/Scri     pt-46EB2E0001C8A0.sh: line 9: /var/folders/2d/_8p7fdvj1v13vkh7wyrbk14h0000gn/T/yarn--1707870956680-0.647996518200334/node: No such file or directory
1101 Command PhaseScriptExecution failed with a nonzero exit code

Reproducer

https://github.com/lindboe/temp-node-reproducer

Screenshots and Videos

No response

Activity

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions