Skip to content

Commit

Permalink
Fix path to node in .xcode.env.local (#43333)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #43333

This change fixes #43285.
Basically, when using a `yarn` alias to install pods, yarn creates a copy of the `node` and `yarn` executables and the `command -v node` command will return the path to that executable.

## Changelog
[iOS][Fixed] - Do not use temporary node when creating the .xcode.env.local

Reviewed By: dmytrorykun

Differential Revision: D54542774

fbshipit-source-id: 3ab0d0bb441988026feff9d5390dcfd10869a1b5
  • Loading branch information
cipolleschi authored and facebook-github-bot committed Jul 18, 2024
1 parent 9504e86 commit 8408b8b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/react-native/scripts/cocoapods/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,18 @@ def self.create_xcode_env_if_missing(file_manager: File)
end

if !file_manager.exist?("#{file_path}.local")
node_binary = `command -v node`
# When installing pods with a yarn alias, yarn creates a fake yarn and node executables
# in a temporary folder.
# Using `type -a` we are able to retrieve all the paths of an executable and we can
# exclude the temporary ones.
# see https://github.com/facebook/react-native/issues/43285 for more info
node_binary = `type -a node`.split("\n").map { |path|
path.gsub!("node is ", "")
}.select { |b|
return !b.start_with?("/var")
}

node_binary = node_binary[0]
system("echo 'export NODE_BINARY=#{node_binary}' > #{file_path}.local")
end
end
Expand Down

0 comments on commit 8408b8b

Please sign in to comment.