Skip to content

Commit

Permalink
Fix path to node in .xcode.env.local
Browse files Browse the repository at this point in the history
Summary:
This change fixes facebook#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.

Differential Revision: D54542774
  • Loading branch information
cipolleschi authored and facebook-github-bot committed Mar 5, 2024
1 parent 1387725 commit daa5b6f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/react-native/scripts/cocoapods/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,21 @@ 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 ", "")
}

if (!node_binary[0].start_with?("/var"))
node_binary = node_binary[0]
else
node_binary = node_binary[1]
end

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

0 comments on commit daa5b6f

Please sign in to comment.