react-native: “launchPackager.command” can’t be opened because (null) is not allowed to open documents in Terminal
Description
I tried to run a react-native
project from the Visual Studio Code own terminal with this command react-native run-android
but I get this error :
How can I solve the error “launchPackager.command” can’t be opened because (null) is not allowed to open documents in Terminal.
with Visual Studio Code in MacMini ?
Version
0.66.1
Output of npx react-native info
System: OS: macOS 13.1 CPU: (8) arm64 Apple M1 Memory: 222.77 MB / 8.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.8.0 - ~/.nvm/versions/node/v16.8.0/bin/node Yarn: Not Found npm: 7.21.0 - ~/.nvm/versions/node/v16.8.0/bin/npm Watchman: Not Found Managers: CocoaPods: Not Found SDKs: iOS SDK: Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1 Android SDK: API Levels: 28, 29, 30, 31, 32, 33 Build Tools: 28.0.3, 29.0.2, 30.0.2, 30.0.3, 31.0.0 System Images: android-29 | Google APIs ARM 64 v8a, android-29 | Google APIs Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: 2021.3 AI-213.7172.25.2113.9123335 Xcode: 14.2/14C18 - /usr/bin/xcodebuild Languages: Java: 15.0.2 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.66.1 => 0.66.1 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Steps to reproduce
npm run android
Snack, code example, screenshot, or link to a repository
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 30
- Comments: 36 (3 by maintainers)
I started facing this issue after upgrading my MacOS to 13.1 (Ventura).
I have solve this error by this:
Set iTerm as the Default Handler for *.command Files
this worked for me.
From the React Native official document to set up the env, it separates starting Metro and building app into two steps:
Start Metro
Build the app then run it
This command won’t start Metro by default
So if you just run
react-native run-android
, the app can be built but when it tries to start, it will fail since there is no Metro service started yet. The launchPackager.command error probably just wanna say this.My suggestion is just following the official document to separate starting Metro and building app into two steps:
Open one terminal in VS Code to run
npm start
to start Metro serviceOpen another terminal to run
npm run ios
to build the app if the app is still not installed on the device or in simulator.If the app is already installed, you don’t need to run this step. You can just start the app directly. Metro will sync all the code changes in your project. So the app on the device or simulator will be always keep updated as long as Metro service is on.
In a nutshell, you don’t need to run this if there is no need to build the app again.
Actually, if you start Metro after the launchPackager.command error shows and then open the app you just built, the app can run without any errors. So I think the launchPackager.command error is just trying to tell you Metro is not on.
I started facing this issue after upgrading my MacOS to 13.1 (Ventura).
A temporary workaround is -
This is due to a known bug in macOS Ventura (13.2) my solution was to disable SIP protection until Apple pushes a fix.
csrutil disable
Thanks for the update @1mehdifaraji, but I’d like to keep this open unless it’s determined that there’s nothing we can do on the RN side to mitigate this - at the moment I’m looking into alternative ways of launching the CLI that won’t trigger SIP.
Bump! I also have this problem running iOS.
info Fetching system and libraries information… System: OS: macOS 13.0.1 CPU: (8) arm64 Apple M1 Pro Memory: 326.80 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.17.1 - ~/.nvm/versions/node/v16.17.1/bin/node Yarn: 1.22.19 - ~/.nvm/versions/node/v16.17.1/bin/yarn npm: 8.15.0 - ~/.nvm/versions/node/v16.17.1/bin/npm Watchman: 2022.11.28.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: Not Found SDKs: iOS SDK: Platforms: DriverKit 22.1, iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1 Android SDK: Not Found IDEs: Android Studio: 2021.3 AI-213.7172.25.2113.9123335 Xcode: 14.1/14B47b - /usr/bin/xcodebuild Languages: Java: 11.0.17 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.1.0 => 18.1.0 react-native: 0.70.5 => 0.70.5 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Always Open With option didn’t show up for me (ventura 13.2.1). Instead I did the following : 1- Control-click the file, then choose Get Info. In the Info window, click the arrow next to “Open with.” 2- Click the pop-up menu, then choose the app. To open all files of this type with this app, click Change All. this worked for me Thank you guys
I’ve started having this issue after installing Fig.
Disabling SIP seems too be going too far just to get rid of that pesky bug…
@shubhambathe1 Yes, it’s quite frustrating. You can also try to simply start the metro server via this command -
npx react-native start
After that, you can run your app as normal, or simply open the installed app in the simulator.Also for the future, using the React Native extension would be helpful: https://github.com/microsoft/vscode-react-native
Fixed the issue by changing the following in
ios/<PROJECT_NAME>.xcodeproj/<PROJECT_NAME>.pbxproj
:ENABLE_USER_SCRIPT_SANDBOXING = YES;
to
ENABLE_USER_SCRIPT_SANDBOXING = NO;
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This worked for me, ran
npx react-native start
and clickedi
to start on ios and it worked properlySimilar to you I upgraded to M2 Ventura and hit the bug, it’s a very good thing to keep it on at all times it prevents other processes to access system files that includes personal data such as your Safari history, imessage DB, and such so turn it on son as a new fix is pushed. More info can be found here
Just be mindful of the packages you download and which processes you give sudo access. One other potential solution I can think of is to downgrade your system to Monterey. My M1 system I upgraded from was on Monterey and had no issues.
That all so worked