Skip to content

Commit 8408b8b

Browse files
cipolleschifacebook-github-bot
authored andcommitted
Fix path to node in .xcode.env.local (#43333)
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
1 parent 9504e86 commit 8408b8b

File tree

1 file changed

+12
-1
lines changed
  • packages/react-native/scripts/cocoapods

1 file changed

+12
-1
lines changed

packages/react-native/scripts/cocoapods/utils.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,18 @@ def self.create_xcode_env_if_missing(file_manager: File)
233233
end
234234

235235
if !file_manager.exist?("#{file_path}.local")
236-
node_binary = `command -v node`
236+
# When installing pods with a yarn alias, yarn creates a fake yarn and node executables
237+
# in a temporary folder.
238+
# Using `type -a` we are able to retrieve all the paths of an executable and we can
239+
# exclude the temporary ones.
240+
# see https://github.com/facebook/react-native/issues/43285 for more info
241+
node_binary = `type -a node`.split("\n").map { |path|
242+
path.gsub!("node is ", "")
243+
}.select { |b|
244+
return !b.start_with?("/var")
245+
}
246+
247+
node_binary = node_binary[0]
237248
system("echo 'export NODE_BINARY=#{node_binary}' > #{file_path}.local")
238249
end
239250
end

0 commit comments

Comments
 (0)