DISPLAY env var setcypress run:Verifying Cypress can run /root/.cache/Cypress/3.2.0/Cypress [failed]
Cypress failed to start.
This is usually caused by a missing library or dependency.
The error below should indicate which dependency is missing.
https://on.cypress.io/required-dependencies
If you are using Docker, we provide containers with all required dependencies installed.
----------
Command failed: /root/.cache/Cypress/3.2.0/Cypress/Cypress --smoke-test --ping=177
----------
Platform: linux (Ubuntu Linux - 18.04)
Cypress Version: 3.2.0
cypress run runs regardless of presence of DISPLAY variable.
--config baseUrl=www.example.comThis was working until a few days ago when we started observing Cypress failed to start.
Inspecting logs we noticed that Semaphore had began injecting a DISPLAY env var. We reached out to Semaphore and they confirmed:
Thanks for reporting this.
The $DISPLAY=:99 change was introduced two days ago as a part of improvements and fixes activities. This change helps with some workflows that are using Selenium/Chrome combination. Since this positively affected a given group of our users, we introduced this change.
I shared this message with the platform team and we will let you know as soon as we have any new information. Until then, please use the workaround you described.
Thanks for your patience.
npm install Cypress 3.2.0Work around is to unset DISPLAY prior to cypress run.
Also identified on https://github.com/cypress-io/cypress/issues/1556#issuecomment-418069209
Yeah, we have definitely seen this reported, but I don't recall anyone tracking down why this is occurring.
Cypress has this code that checks if the OS is linux and if there is NOT a process.env.DISPLAY set, if so - then during cypress run, it evaluates as needing XVFB and also should print needs XVFB? true in the console DEBUG output. How to see your own DEBUG logs
Looks like this is false:
cypress:cli needs XVFB? false +0ms
https://github.com/cypress-io/cypress/blob/develop/cli/lib/exec/xvfb.js#L44
So, assuming you were running on linux and had a DISPLAY env var set, this would evaluate as needs XVFB? false, so then as part of the options, stdio would evaluate to 'inherit' instead of ['inherit', 'inherit', 'pipe']
https://github.com/cypress-io/cypress/blob/devlop/cli/lib/exec/spawn.js#L33
I'm not sure this is relevant.
ALSO, if needsXVFB is false, if will not call into the xvfb.start and instead call into spawn
https://github.com/cypress-io/cypress/blob/develop/cli/lib/exec/spawn.js#L141
https://github.com/cypress-io/cypress/blob/develop/cli/lib/exec/spawn.js#L66
Then I'm a bit lost as to why or where this dependencies error is thrown...which is being caught here:
https://github.com/cypress-io/cypress/blob/issue-1369-configFile-arg/cli/lib/tasks/verify.js#L69
@brian-mann thoughts?
Cypress spins its own XVFB server if there is no DISPLAY variable, to see this in action
docker run -it -v $PWD:/e2e -w /e2e -e DEBUG=cypress:cli,xvfb -e DISPLAY= --entrypoint cypress cypress/included:3.2.0 verify
You should see Cypress messages
cypress:cli using Cypress executable /root/.cache/Cypress/3.2.0/Cypress/Cypress +0ms
cypress:cli needs XVFB? true +0ms
cypress:cli Starting XVFB +0ms
xvfb lock filename /tmp/.X99-lock +0ms
xvfb lock filename /tmp/.X99-lock +1ms
xvfb setting DISPLAY :99 +0ms
xvfb all Xvfb arguments [ ':99' ] +2ms
xvfb checking if started by looking for the lock file /tmp/.X99-lock +4ms
xvfb checking if started by looking for the lock file /tmp/.X99-lock +12ms
xvfb lock file /tmp/.X99-lock found after 10 ms +1ms
cypress:cli smoke test command: /root/.cache/Cypress/3.2.0/Cypress/Cypress --smoke-test --ping=182 +21ms
cypress:cli smoke test stdout "182" +795ms
cypress:cli Stopping XVFB +817ms
xvfb restoring process.env.DISPLAY variable +798ms
xvfb lock filename /tmp/.X99-lock +0ms
xvfb lock file /tmp/.X99-lock +0ms
xvfb lock file /tmp/.X99-lock not found when stopping +67ms
cypress:cli write verified: true +690ms
cypress:cli could not read binary_state.json file +2s
[20:59:25] Verifying Cypress can run /root/.cache/Cypress/3.2.0/Cypress [completed]
But if this variable is set to something else, let's say :100 then verification fails
$ docker run -it -v $PWD:/e2e -w /e2e -e DEBUG=cypress:cli,xvfb -e DISPLAY=:100 --entrypoint cypress cypress/included:3.2.0 verify
cypress:cli cli starts with arguments ["/usr/local/bin/node","/usr/local/bin/cypress","verify"] +0ms
cypress:cli NODE_OPTIONS is not set +0ms
cypress:cli program parsing arguments +2ms
cypress:cli parsed cli options {} +2ms
cypress:cli verifying Cypress app +0ms
cypress:cli checking environment variables +0ms
cypress:cli checking if executable exists /root/.cache/Cypress/3.2.0/Cypress/Cypress +3ms
cypress:cli Binary is executable? : true +2ms
cypress:cli binaryDir is /root/.cache/Cypress/3.2.0/Cypress +0ms
cypress:cli Reading binary package.json from: /root/.cache/Cypress/3.2.0/Cypress/resources/app/package.json +0ms
cypress:cli Found binary version 3.2.0 installed in: /root/.cache/Cypress/3.2.0/Cypress +3ms
cypress:cli { verified: true } +4ms
cypress:cli is Verified ? true +2ms
cypress:cli force verify +0ms
cypress:cli running binary verification check 3.2.0 +1ms
It looks like this is your first time using Cypress: 3.2.0
[21:01:49] Verifying Cypress can run /root/.cache/Cypress/3.2.0/Cypress [started]
cypress:cli clearing out the verified version +5ms
cypress:cli running smoke test +2ms
cypress:cli using Cypress executable /root/.cache/Cypress/3.2.0/Cypress/Cypress +0ms
cypress:cli needs XVFB? false +0ms
cypress:cli smoke test command: /root/.cache/Cypress/3.2.0/Cypress/Cypress --smoke-test --ping=237 +0ms
cypress:cli Smoke test failed: Error: Command failed: /root/.cache/Cypress/3.2.0/Cypress/Cypress --smoke-test --ping=237
at makeError (/usr/local/lib/node_modules/cypress/node_modules/execa/index.js:172:9)
at /usr/local/lib/node_modules/cypress/node_modules/execa/index.js:277:16
at processTicksAndRejections (internal/process/task_queues.js:89:5) {
code: 1,
stdout: '',
stderr: '',
failed: true,
signal: null,
cmd: '/root/.cache/Cypress/3.2.0/Cypress/Cypress --smoke-test --ping=237',
timedOut: false,
killed: false
} +52ms
[21:01:49] Verifying Cypress can run /root/.cache/Cypress/3.2.0/Cypress [failed]
Cypress failed to start.
This is usually caused by a missing library or dependency.
The error below should indicate which dependency is missing.
https://on.cypress.io/required-dependencies
If you are using Docker, we provide containers with all required dependencies installed.
----------
Command failed: /root/.cache/Cypress/3.2.0/Cypress/Cypress --smoke-test --ping=237
----------
Platform: linux (Debian - 9.8)
Cypress Version: 3.2.0
Worse, if we just run tests, then the process fails _silently_
$ docker run -it -v $PWD:/e2e -w /e2e -e DEBUG=cypress:cli,xvfb -e DISPLAY=:100 cypress/included:3.2.0
cypress:cli cli starts with arguments ["/usr/local/bin/node","/usr/local/bin/cypress","run"] +0ms
cypress:cli NODE_OPTIONS is not set +0ms
cypress:cli program parsing arguments +2ms
cypress:cli running Cypress +1ms
cypress:cli parsed cli options {} +33ms
cypress:cli verifying Cypress app +0ms
cypress:cli checking environment variables +1ms
cypress:cli checking if executable exists /root/.cache/Cypress/3.2.0/Cypress/Cypress +2ms
cypress:cli Binary is executable? : true +2ms
cypress:cli binaryDir is /root/.cache/Cypress/3.2.0/Cypress +1ms
cypress:cli Reading binary package.json from: /root/.cache/Cypress/3.2.0/Cypress/resources/app/package.json +0ms
cypress:cli Found binary version 3.2.0 installed in: /root/.cache/Cypress/3.2.0/Cypress +3ms
cypress:cli { verified: true } +4ms
cypress:cli is Verified ? true +2ms
cypress:cli processing run options +0ms
cypress:cli --key is not set, looking up environment variable CYPRESS_RECORD_KEY +1ms
cypress:cli run to spawn.start args ["--run-project","/e2e"] +0ms
cypress:cli needs XVFB? false +0ms
cypress:cli spawning Cypress with executable: /root/.cache/Cypress/3.2.0/Cypress/Cypress +3ms
cypress:cli spawn forcing env overrides { FORCE_COLOR: '1', DEBUG_COLORS: '1', MOCHA_COLORS: '1', FORCE_STDIN_TTY: '1', FORCE_STDOUT_TTY: '1', FORCE_STDERR_TTY: '1' } +0ms
cypress:cli spawn args [ '--run-project', '/e2e', '--cwd', '/e2e' ] { dev: undefined, detached: false, stdio: 'inherit' } +1ms
That's it, there is no more output.
Hmm, we need an actual X11 check there, not just DISPLAY is set and we are good, something like xdpyinfo
$ xdpyinfo
name of display: 10.130.4.201:0
version number: 11.0
vendor string: The X.Org Foundation
vendor release number: 11804000
X.Org version: 1.18.4
Need to check current develop branch to see what it outputs right now for this error on Linux, maybe we can extend the error message with DISPLAY variable (if it is set) and document the problem at https://on.cypress.io/required-dependencies
The code for this is done in cypress-io/cypress#4165, but has yet to be released.
We'll update this issue and reference the changelog when it's released.
Once released, cypress verify will look like this
root@c132eb00fcb5:/app# export export DISPLAY=foo
root@c132eb00fcb5:/app# $(npm bin)/cypress verify
It looks like this is your first time using Cypress: 3.3.0
âš Warning: we have caught a display problem:
[652:0513/212901.933675:WARNING:browser_main_loop.cc(275)] <unknown>: Could not open X display
[652:0513/212901.933884:WARNING:browser_main_loop.cc(275)] Gtk: cannot open display: foo
We will attempt to spin our XVFB server and verify again.
✔ Verified Cypress! /root/.cache/Cypress/3.3.0/Cypress
and cypress run will look like this
root@c132eb00fcb5:/app# export export DISPLAY=foo
root@c132eb00fcb5:/app# $(npm bin)/cypress run
âš Warning: Cypress process has finished very quickly with an error,
which might be related to a potential problem with how the DISPLAY is configured.
DISPLAY was set to "foo"
We will attempt to spin our XVFB server and run Cypress again.
Xlib: extension "RANDR" missing on display ":99".
libudev: udev_has_devtmpfs: name_to_handle_at on /dev: Operation not permitted
Could not find any tests to run.
We looked but did not find a cypress.json file in this folder: /app
Released in 3.3.0.
FWIW - cypress will correctly recover from this situation and will display a warning indicating that it had to try a workaround - but otherwise this issue is completely fixed, nothing else to do.
The warning looks like this...

What does 'fix the problem' mean exactly? What is Cypress doing?
I'm trying to run cypress using headless Chrome. When I do it, I get an error about Xvfb missing:
~ $ cypress run --headless --browser chrome
It looks like this is your first time using Cypress: 4.5.0
✖ Verifying Cypress can run /app/.cache/Cypress/4.5.0/Cypress
→ Cypress Version: 4.5.0
Your system is missing the dependency: Xvfb
Install Xvfb and run Cypress again.
Read our documentation on dependencies for more information:
https://on.cypress.io/required-dependencies
If you are using Docker, we provide containers with all required dependencies installed.
----------
Error: spawn Xvfb ENOENT
----------
Platform: linux (Ubuntu Linux - 18.04)
Cypress Version: 4.5.0
Am I misunderstanding how to run cypress so that Xvfb is not required? Or is Xvfb still required even to run it with headless Chrome?
Most helpful comment
Work around is to
unset DISPLAYprior tocypress run.Also identified on https://github.com/cypress-io/cypress/issues/1556#issuecomment-418069209