-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Metro bundler not starting when running run-android / run-ios command on linux #28807
Comments
Do you know how to run the solution in konsole instead gnome-terminal? |
@ThallyssonKlein The hacky solution should be the same you just need to change in the shgnome the command base. I haven't used konsole so you should investigate how you launch the terminal with that running a script. |
If I use |
@ThallyssonKlein Maybe the konsole is blocking, so try putting the process in background |
The same error happened |
Does this have something to do with the fact that when I build with xcode and no while this does not happen with Yet there are many issues so we don't know where to start... 😢 you really know very well the react-native scripts ... for sure this issue made me waste a lot of time before I noticed the server was not running. Thanks |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions. |
Up. |
This is still an issue. Please some contributor prevent this ticket from going stale. |
Reinstalling android studio with a new emulator or changing the app name in app.json , build.gradle and android manifest.xml solved the issue. |
Confirmed the workaround of @archfz, it worked just fine.
|
Setting |
@nitaigao It doesn't work here (Kde Neon (Ubuntu 20.04)) |
works here in Fedora 33:
You'll probably want to laucn |
For KDE users: |
still experiencing this issue on 0.66 |
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 issue was closed because it has been stalled for 7 days with no activity. |
Description
When running the
react-native run-android
command it tells me that the JS server (metro bundler) is starting, but in fact it does not and the application in the emulator fails to start as of this issue. Runningreact-native start
separately resolves the issue. I think this issue might apply forrun-ios
as well although this needs to be confirmed.React Native version:
react-native: 0.62.2
@react-native-community/cli: 4.8.0
node: 12 // this version does not matter
system: ubuntu 18.04 // this does not matter as well
Steps To Reproduce
Any project with those versions on linux should fail starting the JS server when running
react-native run-android
.Expected Results
react-native run-android
the bundler should be started if it's not started already in a separate terminal window.react-native run-android
and there is an issue with the JS bundler the primary process should display errors why the JS bundler failed starting.Related issues
#25509
#28281
Snack, code example, screenshot, or link to a repository:
I have debugged the issue extensively since none of the related issue provided any solution for my case. I have found several problems with the linux implementation and I will lay them out here. I have also worked out a hacky temporary solution for the fix.
Temporary solution
To hot fix this problem we can leverage the --terminal parameter on
run-android
command. This is very hacky but it worksshgnome
the modified terminal runner in your project root with this content:chmod u+x ./shgnome
.npm run android-linux
.Actual issues
runAndroid
in file@react-native-community/cli-platform-android/build/runAndroid/index.js
. The callstartServerInNewWindow
return value is completely ignored and thus any potential errors are swallowed. This is why I was not getting any errors in the primary process and this is why this issue survives so long. I suggest that if stderr is set than it should be printed or thrown, but this depends also on the other fixes required.react-native/scripts/launchPackager.command
. This file does not have the -e cmd flag and thus it does not exit with proper error code if things fail in it's process. This was also influencing the 1. issue since if the flag is set then we get proper error message in the primary process (run-android) that the JS bundler failed to start and why it failed.startServerInNewWindow
function in@react-native-community
spawns thelaunchPackager.command
process in an sh shell, while in fact thelaunchPackager.command
explicitly says that it require bash. Because that shellscript was written for bash when it runs with sh it fails due to syntax differences. This failure is not printed to the console of the primary process and is not detected because of issue 2. For this I would suggest letting the shellscript decide in what to run itself and just be called directly as the hot-fix shows. But I am not sure why sh was enforced there and so input is required for this. Note that the code below is modified in the catch case when the terminal is not set with my proposed solution. The try block is the old one as you can see has the sh. I would also suggest not doing the fallback as such and rather if --terminal is set and it does not work just throw an error to the user. The current fallback implementation is unnecessary slower in cases where the the --terminal is not set and it's bad developer experience if the --terminal is set but in fact it doesn't work.gnome-terminal
as can be seen above: this allows to open a separate window and set the blunder to be a separate process.I would also suggest having tests for the metro bundler auto start.
The text was updated successfully, but these errors were encountered: