question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Presence of DISPLAY env var causes "Cypress failed to start"

See original GitHub issue

Current behavior:

  1. Have DISPLAY env var set
  2. cypress 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

Desired behavior:

cypress run runs regardless of presence of DISPLAY variable.

Steps to reproduce: (app code and test code)

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

Versions

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
davetapleycommented, Apr 25, 2019

Work around is to unset DISPLAY prior to cypress run.

Also identified on https://github.com/cypress-io/cypress/issues/1556#issuecomment-418069209

1reaction
bahmutovcommented, May 7, 2019

Cypress spins its own XVFB server if there is no DISPLAY variable, to see this in action

  • start Docker locally
  • from any folder execute the command
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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cypress failed to start on Windows - Stack Overflow
1 Cypress failed to start. This is usually caused by a missing library or dependency. The error below should indicate which dependency is...
Read more >
Using Cypress - Cypress Documentation
Will Cypress fail the test when an application has unhandled rejected promise? Can I override environment variables or create configuration for different ...
Read more >
Changelog - Cypress Documentation
Fixed a regression introduced in the Electron browser in Cypress 10.8.0 where the CYPRESS_EVERY_NTH_FRAME environment variable was not being set appropriately ...
Read more >
Conditional Testing - Cypress Documentation
The problem is - while first appearing simple, writing tests in this fashion often leads to flaky tests, random failures, and difficult to...
Read more >
Environment Variables | Cypress Documentation
Set in your configuration file · Create a cypress.env.json · Export as CYPRESS_* · Pass in the CLI as --env · Set an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found