codesandbox-client icon indicating copy to clipboard operation
codesandbox-client copied to clipboard

Error: spawn xdg-open ENOENT

Open huturen opened this issue 4 years ago • 14 comments

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

image
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

Go to this link

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

huturen avatar Apr 18 '22 17:04 huturen

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

JamesACS avatar Apr 29 '22 15:04 JamesACS

Many thanks. @JamesACS

huturen avatar May 01 '22 03:05 huturen

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?

Fanxin-Yang avatar Aug 08 '22 13:08 Fanxin-Yang

1663226368438

Change this fix the issue.

Jiancong avatar Sep 15 '22 07:09 Jiancong

I have the same problem and use the following command to solve it:

sudo` apt-get install xdg-utils

lee-bran avatar Feb 04 '23 19:02 lee-bran

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

stevenbdf avatar Feb 25 '23 04:02 stevenbdf

I have the same problem and use the following command to solve it:

sudo` apt-get install xdg-utils

thx, it worked for me

Pablitox26 avatar Jun 05 '23 01:06 Pablitox26

1663226368438

Change this fix the issue.

I had to use vite --no-open for it to work.

pypae avatar Aug 22 '23 07:08 pypae

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.

RampagerB avatar Sep 01 '23 02:09 RampagerB

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.

Thank you this was the problem.

bestii avatar Apr 09 '24 14:04 bestii

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
  },
  },

Gautam-Hegde avatar Jun 23 '24 17:06 Gautam-Hegde

add --host in my package.json in script solves for me:

"docker-dev": "vite dev --host"

lucasquin avatar Sep 09 '24 15:09 lucasquin

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.

zach-betz-hln avatar Oct 25 '24 14:10 zach-betz-hln

I had to use vite --no-open for 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.

vincerubinetti avatar Jul 15 '25 20:07 vincerubinetti