cypress: Error: Could not start Xvfb. Install XVFB and run Cypress again.
Hi, folks! I’m using Cypress to run an end-to-end testing suite against an application I work on. I’ve been running into a really weird issue with the docker images, one which only seems to happen on our CI (TeamCity); I haven’t been able to reproduce it locally.
Running cypress verify in the Docker image ends up failing and saying that Xvfb is not installed, even though it’s listed in the Dockerfile as a dependency to be installed. Simply restarting a build is enough to get the Docker setup back into the right state, and then the tests can run just fine. Here is a log of pulling and starting the Cypress docker image; between failing and passing builds, nothing changes. The same image sha ends up being pulled but sometimes fails to detect Xvfb.
[09:07:49] [Step 3/11] Temporary file was created: /opt/teamcity-agent/work/5c5a013f643109a5/Dockerfile_TC_1523290069059-temp
[09:07:49] [Step 3/11] Starting: docker build -t SCRUBBED --pull --label "branch=refs/heads/master" --label "commit=SCRUBBED" -f /opt/teamcity-agent/work/5c5a013f643109a5/Dockerfile_TC_1523290069059-temp .
[09:07:49] [Step 3/11] in directory: /opt/teamcity-agent/work/5c5a013f643109a5
[09:07:49] [Step 3/11]
[09:07:49] [Step 3/11] Step 1/6 : FROM cypress/base:8
[09:07:50] [Step 3/11] 8: Pulling from cypress/base
[09:07:50] [Step 3/11] f2b6b4884fc8: Already exists
[09:07:50] [Step 3/11] 4fb899b4df21: Already exists
[09:07:50] [Step 3/11] 74eaa8be7221: Already exists
[09:07:51] [Step 3/11] 2d6e98fe4040: Already exists
[09:07:51] [Step 3/11] 452c06dec5fa: Pulling fs layer
[09:07:51] [Step 3/11] 7b3c215894de: Pulling fs layer
[09:07:51] [Step 3/11] c62e8e1f22ef: Pulling fs layer
[09:07:51] [Step 3/11] 93263a0b6217: Pulling fs layer
[09:07:51] [Step 3/11] 344085b70f46: Pulling fs layer
[09:07:51] [Step 3/11] f18709ef8150: Pulling fs layer
[09:07:51] [Step 3/11] 16b62243dd9a: Pulling fs layer
[09:07:51] [Step 3/11] f18709ef8150: Waiting
[09:07:51] [Step 3/11] 344085b70f46: Waiting
[09:07:51] [Step 3/11] 16b62243dd9a: Waiting
[09:07:51] [Step 3/11] 93263a0b6217: Waiting
[09:07:51] [Step 3/11] 452c06dec5fa: Verifying Checksum
[09:07:51] [Step 3/11] 7b3c215894de: Download complete
[09:07:51] [Step 3/11] 452c06dec5fa: Pull complete
[09:07:51] [Step 3/11] 7b3c215894de: Pull complete
[09:07:51] [Step 3/11] c62e8e1f22ef: Verifying Checksum
[09:07:51] [Step 3/11] c62e8e1f22ef: Download complete
[09:07:51] [Step 3/11] 93263a0b6217: Verifying Checksum
[09:07:51] [Step 3/11] 93263a0b6217: Download complete
[09:07:52] [Step 3/11] 16b62243dd9a: Verifying Checksum
[09:07:52] [Step 3/11] 16b62243dd9a: Download complete
[09:07:52] [Step 3/11] f18709ef8150: Verifying Checksum
[09:07:53] [Step 3/11] c62e8e1f22ef: Pull complete
[09:07:53] [Step 3/11] 344085b70f46: Verifying Checksum
[09:07:53] [Step 3/11] 344085b70f46: Download complete
[09:07:53] [Step 3/11] 93263a0b6217: Pull complete
[09:07:57] [Step 3/11] 344085b70f46: Pull complete
[09:07:58] [Step 3/11] f18709ef8150: Pull complete
[09:07:58] [Step 3/11] 16b62243dd9a: Pull complete
[09:07:58] [Step 3/11] Digest: sha256:d82d1db790e5a585b1db2e0f8fe3ff343d981ba18db477e40a0b498e04c73e23
[09:07:58] [Step 3/11] Status: Downloaded newer image for cypress/base:8
[09:07:58] [Step 3/11] ---> ed9c4e411f39
[09:07:58] [Step 3/11] Step 2/6 : ADD integration-tests /src/integration-tests
[09:07:59] [Step 3/11] ---> 14d57ea2af4d
[09:07:59] [Step 3/11] Removing intermediate container 66e0363b40eb
[09:07:59] [Step 3/11] Step 3/6 : WORKDIR /src/integration-tests
[09:07:59] [Step 3/11] ---> 3071a36c58b5
[09:07:59] [Step 3/11] Removing intermediate container 478a01054b29
[09:07:59] [Step 3/11] Step 4/6 : RUN yarn install
[09:07:59] [Step 3/11] ---> Running in e9ca1a3678ff
[09:08:05] [Step 3/11] yarn install v1.5.1
[09:08:05] [Step 3/11] [1/4] Resolving packages...
[09:08:06] [Step 3/11] [2/4] Fetching packages...
[09:08:10] [Step 3/11] [3/4] Linking dependencies...
[09:08:12] [Step 3/11] [4/4] Building fresh packages...
[09:08:52] [Step 3/11] Done in 46.50s.
[09:09:00] [Step 3/11] ---> b8cb0306c75a
[09:09:03] [Step 3/11] Removing intermediate container e9ca1a3678ff
[09:09:03] [Step 3/11] Step 5/6 : RUN $( yarn bin )/cypress verify
[09:09:03] [Step 3/11] ---> Running in 109a9fd4ae07
[09:09:04] [Step 3/11] It looks like this is your first time using Cypress: 2.1.0
[09:09:04] [Step 3/11]
[09:09:04] [Step 3/11] [16:09:04] Verifying Cypress can run /src/integration-tests/node_modules/cypress/dist/Cypress [started]
[09:09:06] [Step 3/11] [16:09:06] Verifying Cypress can run /src/integration-tests/node_modules/cypress/dist/Cypress [failed]
[09:09:06] [Step 3/11] [16:09:06] → Your system is missing the dependency: XVFB
[09:09:06] [Step 3/11]
[09:09:06] [Step 3/11] Install XVFB and run Cypress again.
[09:09:06] [Step 3/11]
[09:09:06] [Step 3/11] Read our documentation on dependencies for more information:
[09:09:06] [Step 3/11]
[09:09:06] [Step 3/11] https://on.cypress.io/required-dependencies
[09:09:06] [Step 3/11]
[09:09:06] [Step 3/11] If you are using Docker, we provide containers with all required dependencies installed.
[09:09:06] [Step 3/11] ----------
[09:09:06] [Step 3/11]
[09:09:06] [Step 3/11] Caught error trying to run XVFB: "Your system is missing the dependency: XVFB
[09:09:06] [Step 3/11]
[09:09:06] [Step 3/11] Install XVFB and run Cypress again.
[09:09:06] [Step 3/11]
[09:09:06] [Step 3/11] Read our documentation on dependencies for more information:
[09:09:06] [Step 3/11]
[09:09:06] [Step 3/11] https://on.cypress.io/required-dependencies
[09:09:06] [Step 3/11]
[09:09:06] [Step 3/11] If you are using Docker, we provide containers with all required dependencies installed.
[09:09:06] [Step 3/11] ----------
[09:09:06] [Step 3/11]
[09:09:06] [Step 3/11] Error: Could not start Xvfb.
[09:09:06] [Step 3/11] ----------
[09:09:06] [Step 3/11]
[09:09:06] [Step 3/11] Platform: linux (Debian - 8.10)
[09:09:06] [Step 3/11] Cypress Version: 2.1.0"
[09:09:06] [Step 3/11] ----------
[09:09:06] [Step 3/11]
[09:09:06] [Step 3/11] Platform: linux (Debian - 8.10)
[09:09:06] [Step 3/11] Cypress Version: 2.1.0
[09:09:06] [Step 3/11] Your system is missing the dependency: XVFB
[09:09:06] [Step 3/11]
[09:09:06] [Step 3/11] Install XVFB and run Cypress again.
[09:09:06] [Step 3/11]
[09:09:06] [Step 3/11] Read our documentation on dependencies for more information:
[09:09:06] [Step 3/11]
[09:09:06] [Step 3/11] https://on.cypress.io/required-dependencies
[09:09:06] [Step 3/11]
[09:09:06] [Step 3/11] If you are using Docker, we provide containers with all required dependencies installed.
[09:09:06] [Step 3/11] ----------
[09:09:06] [Step 3/11]
[09:09:06] [Step 3/11] Caught error trying to run XVFB: "Your system is missing the dependency: XVFB
[09:09:06] [Step 3/11]
[09:09:06] [Step 3/11] Install XVFB and run Cypress again.
[09:09:06] [Step 3/11]
[09:09:06] [Step 3/11] Read our documentation on dependencies for more information:
[09:09:06] [Step 3/11]
[09:09:06] [Step 3/11] https://on.cypress.io/required-dependencies
[09:09:06] [Step 3/11]
[09:09:06] [Step 3/11] If you are using Docker, we provide containers with all required dependencies installed.
[09:09:06] [Step 3/11] ----------
[09:09:06] [Step 3/11]
[09:09:06] [Step 3/11] Error: Could not start Xvfb.
[09:09:06] [Step 3/11] ----------
[09:09:06] [Step 3/11]
[09:09:06] [Step 3/11] Platform: linux (Debian - 8.10)
[09:09:06] [Step 3/11] Cypress Version: 2.1.0"
[09:09:06] [Step 3/11] ----------
[09:09:06] [Step 3/11]
[09:09:06] [Step 3/11] Platform: linux (Debian - 8.10)
[09:09:06] [Step 3/11] Cypress Version: 2.1.0
[09:09:07] [Step 3/11] The command '/bin/sh -c $( yarn bin )/cypress verify' returned a non-zero code: 1
[09:09:07] [Step 3/11] The command '/bin/sh -c $( yarn bin )/cypress verify' returned a non-zero code: 1
[09:09:07] [Step 3/11]
[09:09:07] [Step 3/11] Process exited with code 1
[09:09:07] [Step 3/11] Process exited with code 1
[09:09:07] [Step 3/11] Step ♀️ build integration-tests docker image (Docker Build) failed
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 18
- Comments: 51 (14 by maintainers)
We have the same problem on version 3.1.0
We has this same problem with Jenkins. Someone fixed it?
I’ve also reproduced this issue on gitlab-ci.
I’m still seeing this on GitLab CI with cypress v3.6.1
Still having this issue on Cypress 3.4.1 on Bitbucket pipelines:
I’m sure that XVFB is installed
Landing here with the same error on Gitlab CI. When I use
cypress/base:10and use Electron, it works fine. If I switch tocypress/browsers:chrome67orcypress/browsers:chrome69and run Cypress with browser set to Chrome, I get the error above all the time.The fix will for this will be released in 3.5.0. The bug will exist in 3.4.1 as noted in this comment: https://github.com/cypress-io/cypress/issues/5110#issuecomment-530019785
We will try to release it this month, meanwhile, it is possible to patch Cypress NPM module yourself, see how https://docs.cypress.io/guides/guides/debugging.html#Patch-Cypress
@yuguangchuan
it worked for me. 😃
Last time I met this issue, the root cause is that the “Xvfb” process is already running, and cypress can not start it with errors like:
Then I checked that there’re really some running processes of
Xvfbin system,and after I killed them everything went well.
So in my case, this is not a problem with Cypress. Hope it helps.
It seems like I just forgot to install the dependencies. It worked after installing those. https://docs.cypress.io/guides/guides/continuous-integration.html#Dependencies
This is a 5 second timeout set in https://github.com/cypress-io/cypress/blob/develop/cli/lib/exec/xvfb.js#L11 It seems like a very short and we should just increase it 30 seconds. Let me move this issue main Cypress repo so I can do the increase
It did actually - it was not correctly set to a milestone so it was missed when doing the changelog.
It was bumped up to 5 seconds… but now that I think about it, I have no idea why we wouldn’t set it to something like 30 seconds. I have seen situations where builds fail due to shutting off xvfb or starting it up.
https://github.com/cypress-io/cypress/blob/97e3092300e4487e9db01ad33d0ebb0acee7b4f2/cli/lib/exec/xvfb.js#L10
Yes, we are increasing the default xvfb start time out from 2 seconds to 5 seconds in cypress 3.0.0
Sent from my iPhone
@AveVlad Sorry, but that seems unrelated to the problem reported in this issue, which is Xvfb failing to start in the first place when using the docker image.
If we can have exact dockerfile, setup instructions and the minimal test repository, we could debug this to find which system is failing.
Sent from my iPhone
Interesting, and we see this randomly on TravisCI when using Docker - XVFB not being detected, but restarting the build solves it. I wonder if increasing the timeout when passed as an option to https://github.com/cypress-io/xvfb/blob/master/index.js would solve this problem. This is so transient that we did not look into this, but seems different CIs can encounter it