Error: spawn xdg-open ENOENT
🐛 bug report
Preflight Checklist
- [X] I have read the Contributing Guidelines for this project.
- [X] I agree to follow the Code of Conduct that this project adheres to.
- [X] I have searched the issue tracker for an issue that matches the one I want to file, without success.
Description of the problem
Could not start service in the codesandbox below, command line threw "Error: spawn xdg-open ENOENT" error.
sandbox@sse-sandbox-gnbzrk:/sandbox$ yarn dev
yarn run v1.22.17
$ http-request-mock-cli -t es6 -e none -w "vite --config ./config/vite.config.dev.ts --host"
this.appRoot: /sandbox/
[http-request-mock] Watching: /sandbox/mock
vite v2.9.5 dev server running at:
> Local: http://localhost:3000/
> Network: http://192.168.203.6:3000/
ready in 388ms.
events.js:377
throw er; // Unhandled 'error' event
^
Error: spawn xdg-open ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:274:19)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:82:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:280:12)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn xdg-open',
path: 'xdg-open',
spawnargs: [ 'http://localhost:3000/' ]
}
How has this issue affected you? What are you trying to accomplish?
To Reproduce
Your Environment
| Software | Name/Version |
|---|---|
| Сodesandbox | https://codesandbox.io/s/github/huturen/http-request-mock-curd/tree/main |
| Browser | Google Chrome 100.0.4896.88 (x86_64) |
| Operating System | MacOS |
Hey @huturen,
This error is (almost) always caused because either:
- The command doesn't exist
or
- The directory doesn't exist.
It can also be caused by a windows specific issue, but that's not relevant here!
You can wrap the original spawn cell with a wrapped which prints the arguments sent to the spawn cell which will give you a more specific error to help you debug
Many thanks. @JamesACS
Hi! I've got the same problem when I'm trying to run the application on a server with Ubuntu 20.04.4 LTS. However it works fine on MacOS locally.
Can you please explain more about how to wrap the original spawn cell with a wrapped?
Change this fix the issue.
I have the same problem and use the following command to solve it:
sudo` apt-get install xdg-utils
I have the same problem and use the following command to solve it:
sudo` apt-get install xdg-utils
For people having issues connecting to decontainers from JetBrain Gateway and IDEs. This worked for me ^ Thanks @lee-bran
I have the same problem and use the following command to solve it:
sudo` apt-get install xdg-utils
thx, it worked for me
![]()
Change this fix the issue.
I had to use vite --no-open for it to work.
I may found out why this happens.
In your vite.config.ts you may set open: true or in your package.json "dev": "vite --open", this open means it'll try to open your browser after start the dev server, but in some server they don't have a browser, so error shows.
I may found out why this happens. In your
vite.config.tsyou may setopen: trueor in your package.json"dev": "vite --open", thisopenmeans it'll try to open your browser after start the dev server, but in some server they don't have a browser, so error shows.
Thank you this was the problem.
I have the same problem and use the following command to solve it:
sudo` apt-get install xdg-utils
Additionally, using host:true in the Vite config worked for me
plugins: [react()],
server: {
port: 3000,
host: true,
open: true
},
},
add --host in my package.json in script solves for me:
"docker-dev": "vite dev --host"
This error was happening for me when vite was trying to open the browser in the container.
Fixed it by setting server.open to false.
See docs.
I had to use
vite --no-openfor it to work.
Not sure what this comment and this issue are talking about with the --no-open flag, because by default Vite won't open the URL. I'd say maybe they changed it in newer versions of Vite, but I've been using it since v4 and that's always been the case.
Looking at the code, the --no- prefix is a general way to add a "negative" to any CLI option, and it comes from the cac library.
But again there should be no reason to add it, because simply removing --open will make Vite not open the URL, which I believe has always been the case.