From eeaa3ff458a3e5c902075bb45161d6ccde31fe53 Mon Sep 17 00:00:00 2001 From: Blake Friedman Date: Wed, 9 Oct 2024 04:14:31 -0700 Subject: [PATCH] Let .xcode.env.local NODE_BINARY handle path spaces 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 --- packages/react-native/scripts/cocoapods/utils.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/react-native/scripts/cocoapods/utils.rb b/packages/react-native/scripts/cocoapods/utils.rb index fa175cac13144a..510e084f600ec6 100644 --- a/packages/react-native/scripts/cocoapods/utils.rb +++ b/packages/react-native/scripts/cocoapods/utils.rb @@ -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 @@ -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