Skip to content

Update .xcode.env.local on pod install when its node no longer exists - #59539

Open
lazerg wants to merge 3 commits into
react:mainfrom
lazerg:fix/issue-59538-stale-xcode-env-local
Open

lazerg wants to merge 3 commits into
react:mainfrom
lazerg:fix/issue-59538-stale-xcode-env-local

Conversation

@lazerg

@lazerg lazerg commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

pod install only writes ios/.xcode.env.local when the file is missing. The Xcode script phases source it after .xcode.env, so its absolute NODE_BINARY wins. Once a version manager removes that node (nvm installing a newer one and uninstalling the old), every build fails in the first script phase that runs node, and running pod install again doesn't help because the file already exists.

create_xcode_env_if_missing now checks the NODE_BINARY the file exports. If it's an absolute path that no longer exists, that line is replaced with the current node and the rest of the file is kept. Files pointing at an existing node, or using something other than an absolute path (like $(command -v node)), are left alone.

Fixes #59538

Changelog:

[IOS] [FIXED] - Update .xcode.env.local on pod install when the node it points to was removed

Test Plan:

Added test_createXcodeEnvIfMissing_whenLocalNodeIsMissing_updatesNodeBinary to utils-test.rb and updated the "present" test to read a local file whose node exists. ruby -Itest cocoapods/__tests__/utils-test.rb passes, except test_SetGCCPreprocessorDefinitionForHermes_itSetsThePreprocessorForDebug, which fails the same way on main locally.

Also ran create_xcode_env_if_missing against a real folder: a .xcode.env.local pointing at a removed nvm node gets its NODE_BINARY line updated, while existing paths, escaped-space paths and $(command -v node) are left alone.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 27, 2026
@lazerg lazerg changed the title Recreate .xcode.env.local on pod install when its node no longer exists Update .xcode.env.local on pod install when its node no longer exists Oct 27, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Oct 27, 2026

@cipolleschi cipolleschi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks for the fix

@meta-codesync

meta-codesync Bot commented Oct 27, 2026

Copy link
Copy Markdown

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this in D127824392.

@cipolleschi cipolleschi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the fix. We discovered an edge case. Could you address it, please?

file_manager.write("#{file_path}.local", local_env.gsub(/^export NODE_BINARY=.+$/) { "export NODE_BINARY=#{node_binary}" })
else
system("echo 'export NODE_BINARY=#{node_binary}' > #{file_path}.local")
end

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Empty/malformed NODE_BINARY value treated as valid, leaving broken file unrepaired
local_node_binary_exists? returns true when the captured NODE_BINARY is nil, but an empty line export NODE_BINARY= fails the (.+) capture and produces nil — so a file with an empty/unset NODE_BINARY is considered valid and left untouched. This is exactly the broken-build state the diff is meant to repair, so the build continues to fail.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, fixed in c951f79. An empty value, including "", now counts as broken and gets replaced on pod install. I added a test for it.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Visual regression

No visual differences at c951f796354b.

android: no capture

This branch has not been deployed

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iOS: pod install keeps an ios/.xcode.env.local whose node was removed, so every build fails after a node upgrade

2 participants