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 :

0vwXu-1

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

0vwXu-1

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 30
  • Comments: 36 (3 by maintainers)

Most upvoted comments

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

  • Open node_modules/react-native/scripts/ in Finder (open node_modules/react-native/scripts/)
  • Right-Click on launchPackager.command and click Open With then choose Other…
  • In your Applications directory, select iTerm and click Always Open With

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

    npx react-native start
    
  • Build the app then run it

    npx react-native run-ios
    

    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:

  1. Open one terminal in VS Code to run npm start to start Metro service

  2. Open 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 -

  1. Open node_modules > react-native > scripts folder for that particular app.
  2. Run the file named launchPackager.command
  3. Reload App (If needed).

This is due to a known bug in macOS Ventura (13.2) my solution was to disable SIP protection until Apple pushes a fix.

  1. Boot into recovery mode by press and hold the power button
  2. Access Terminal
  3. type csrutil disable
  4. Restart

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

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

* Open node_modules/react-native/scripts/ in Finder (open node_modules/react-native/scripts/)

* Right-Click on launchPackager.command and click Open With then choose Other...

* In your Applications directory, select iTerm and click Always Open With

this worked for me.

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

Screenshot 2023-03-03 at 16 15 35 Screenshot 2023-03-03 at 16 19 57 Screenshot 2023-03-03 at 16 20 44

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.

From the React Native official document to set up the env, it separates starting Metro and building app into two steps:

  • Start Metro
    npx react-native start
    

This worked for me, ran npx react-native start and clicked i to start on ios and it worked properly

This is due to a known bug in macOS Ventura (13.2) my solution was to disable SIP protection until Apple pushes a fix.

  1. Boot into recovery mode by press and hold the power button
  2. Access Terminal
  3. type csrutil disable
  4. Restart

Thanks, worked for me. I recently migrated my system from Intel to M1. Everything was fine and at one moment metro did not start with the emulator, following this topic I tried to manually open and run through the terminal, everything worked, but it did not start with the emulator 😦 As a result, I tried to follow these steps and everything worked, it starts again with the emulator 😃 I didn’t find any information about how safe this command is, but I hope everything will be fine

Similar 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.

I started facing this issue after upgrading my MacOS to 13.1 (Ventura).

A temporary workaround is -

  1. Open node_modules > react-native > scripts folder for that particular app.
  2. Run the file named launchPackager.command
  3. Reload App (If needed).

That all so worked