“launchPackager.command” can’t be opened
Asked Answered
M

9

14

Just updated my Mac to the official release of Ventura, and I cannot launch my application via react-native run-ios.

Expected behavior:

running react-native run-ios will launch an Xcode simulator and a terminal window with Metro running.

Current behavior:

Xcode simulator opens, main terminal says app was built successfully, but an error is thrown instead of the metro terminal opening:

“launchPackager.command” can’t be opened because (null) is not allowed to open documents in Terminal.

The simulator just shows a white screen and can't be interacted with.

What I've tried:

  • manually opening node_modules/react-native/scripts/launchPackager.command
    • opens Metro terminal but is not connected to the app

warn No apps connected. Sending "reload" to all React Native apps failed. Make sure your app is running in the simulator or on a phone connected via USB. info Reloading app...

  • giving Terminal full disk access (no change)
Mercurochrome answered 24/10, 2022 at 23:23 Comment(2)
@author were you able to solve this issue?Coxcombry
@KartikBhalla the solution below by gpmcadam worked for me. I was using the warp terminal at the time, but have switched back to iTerm and it works for that as well.Mercurochrome
H
31

This happened to me after upgrading to macOS Ventura. I happen to use iTerm as my main terminal, not the built-in Terminal.app so the following fix only applies to that scenario:

Set iTerm as the Default Handler for *.command Files

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

After this, you might need to run npm run ios again from this terminal window. However, from now on, Metro will open in a new iTerm tab instead of trying to open the command in a new Terminal window.

For me, this was the desired behaviour and it removed this warning.

Note In future, any *.command files will now open with iTerm instead of Terminal.

Hager answered 29/10, 2022 at 10:48 Comment(4)
This sorta works for me, and I had essentially found the same workaround but using the Warp terminal. It's just a little frustrating that the command doesn't run automatically. I still have to close the app in simulator, reopen, and reload metro to get it to bundleMercurochrome
What about android ? I run the command react-native run-android and I get the error only in the visual studio code own terminal and not with the Terminal app itself .Jillian
Actually I don't see iTerm in my Applications folderSacroiliac
If not finding it in Applications, look in Utilities folder, then should see TerminalKnawel
Z
13

In project.pbxproj file Change ENABLE_USER_SCRIPT_SANDBOXING = YES; to ENABLE_USER_SCRIPT_SANDBOXING = NO;

And run the simulator with usual command

  • For IOS - npx react-native run-ios
Zawde answered 12/10, 2023 at 7:47 Comment(0)
G
5

I encountered the same problem as you, I installed another terminal (iTerm2), then randomly found a .command file, and in the display introduction, changed the default opening method to iTerm2enter image description here

Guttate answered 30/10, 2022 at 16:48 Comment(0)
S
3

I'm having this issue after upgrading my MacOS to Ventura 13.1.

If you don't want to use iTerm as the accepted answer suggest, the workaround I found was to look for the launchPackager.command file inside node-modules/react-native/scripts/ and open this file manually every time you run your app for the first time (specifically when the error pop-up appears). This will open the terminal with metro running already.

I know that manually processes are not the best, but I don't want to use iTerm :)

Suasion answered 19/1, 2023 at 11:45 Comment(0)
M
2

For Most of the case you just have to delete node_modules and install modules again (npm i). This happens when project was copied from old mac which had node_modules folder created by the old user, or if the system thinks so

This happened to me after i configured my terminal for the look and feel - but with iterm2, oh my zsh, and powerlevel10k

Merrie answered 3/2, 2023 at 4:49 Comment(0)
P
1

Using Intel version of apps (Webstorm, Android Studio, other IDE etc...) fixed my problems. I encountered the same issue and thanks to Intel version of Webstorm and Xcode on Rosetta I can able to pod install and other operations.

Note: I'm using Intel version of Android Studio, WebStorm. Also Xcode uses Rosetta 2. No problem detected and everything works perfect. I can able to develop React-Native & Native Android & iOS and Flutter apps without problem. Before that I was using Silicon version of WebStorm and almost no function worked.

Config: MacBook Air, macOS Ventura 13.2 on Apple M1 processor.

enter image description here

enter image description here

Polyp answered 30/1, 2023 at 12:12 Comment(0)
L
1

Are you using VSCode terminal to run the command? If so, try running the command on the Mac default terminal instead.

Lacrosse answered 1/3, 2023 at 16:55 Comment(0)
E
1

I encountered the same problem as you, I found a workaround for that, just run this command in the VSCode terminal

npm run start

in another tab run this:

npx react-native run-ios

or

npx react-native run-ios --simulator="iPhone 14"
Elegance answered 13/7, 2023 at 11:54 Comment(0)
E
1

In my case, It happened, cause zsh update alert was opened at the same time. May be, You also could see this alert, "do you want to update zsh or no" so I guess this alert disturbs automatically running metro server on Iterm or Iterm2 terminal. so, I just updated followed by this alert, and then, It work well.

I referenced this answer. https://mcmap.net/q/752481/-react-native-launchpackager-command-cant-be-opened

Epiblast answered 27/9, 2023 at 7:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.