fix: force server to always start in a new window on macOS #2628
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes an issue on macOS where the server wasn't reliably being launched in a new terminal window. The solution involves using the
-naflag combination with theopencommand instead of just-a, which ensures that a new instance of the terminal application is always created.As per the man entry for
open:DESCRIPTION The open command opens a file (or a directory or URL), just as if you had double-clicked the file's icon. If no application name is specified, the default application as determined via LaunchServices is used to open the specified files. [...] -n Open a new instance of the application(s) even if one is already running.The issue was identified in a Ghostty discussion which pointed out that some terminals work around the fact that
open -adoes not inherit the current environment it's being run in by explicitly injecting the environment variables, the standard and reliable way to ensure a new window is created and the environment variables are correctly set is to use the-nflag explicitly with the macOSopencommand.This change ensures consistent behavior across all terminal emulators on macOS.
Test Plan
I've verified this change by:
To test this yourself:
npx react-native startChecklist
react-nativecheckout (instructions).