Skip to content

Commit

Permalink
Let .xcode.env.local NODE_BINARY handle path spaces
Browse files Browse the repository at this point in the history
Summary:
For users who may have node installed in a path with a space, this requires escaping.  For example:

```
NODE_BINARY=/Users/blakef/Library/Application Support/fnm/node-versions/v20.12.0/installation/bin/node
```

Needs to be:

```
NODE_BINARY=/Users/blakef/Library/Application\ Support/fnm/node-versions/v20.12.0/installation/bin/node
```

# Changelog
[iOS][Fixed] Generated NODE_BINARY in .xcode.env.local now supports paths with a space

Reviewed By: cipolleschi

Differential Revision: D64080118

fbshipit-source-id: 1045473e4fd284fc570fa538984618630be1af6d
  • Loading branch information
blakef authored and facebook-github-bot committed Oct 9, 2024
1 parent 5f00db9 commit eeaa3ff
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/react-native/scripts/cocoapods/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

require 'shellwords'

require_relative "./helpers.rb"

# Utilities class for React Native Cocoapods
Expand Down Expand Up @@ -237,8 +239,8 @@ def self.create_xcode_env_if_missing(file_manager: File)
# When installing pods with a yarn alias, yarn creates a fake yarn and node executables
# in a temporary folder.
# Using `node --print "process.argv[0]";` we are able to retrieve the actual path from which node is running.
# see https://github.com/facebook/react-native/issues/43285 for more info
node_binary = `node --print "process.argv[0]";`
# see https://github.com/facebook/react-native/issues/43285 for more info. We've tweaked this slightly.
node_binary = Shellwords.escape(`node --print "process.argv[0]"`.strip)
system("echo 'export NODE_BINARY=#{node_binary}' > #{file_path}.local")
end
end
Expand Down

0 comments on commit eeaa3ff

Please sign in to comment.