Running Cypress on WSL
Asked Answered
T

5

21

I'm trying to run cypress on a WSL with Ubuntu, this is what I'm getting:

$ cypress run
[29023:1018/155130.159647:ERROR:bus.cc(392)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[29023:1018/155130.162020:ERROR:bus.cc(392)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[29023:1018/155130.162068:ERROR:bus.cc(392)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[29211:1018/155130.193707:ERROR:gpu_init.cc(441)] Passthrough is not supported, GL is swiftshader

...

[29023:1018/155132.292604:ERROR:bus.cc(392)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")

Timed out waiting for the browser to connect. Retrying...
[29023:1018/155232.249036:ERROR:bus.cc(392)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")

Timed out waiting for the browser to connect. Retrying again...
[29023:1018/155332.249372:ERROR:bus.cc(392)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
 (-2) loading 'http://localhost:3000/__/#/tests/integration/simple.spec.ts'
Error:  (-2) loading 'http://localhost:3000/__/#/tests/integration/simple.spec.ts'
    at rejectAndCleanup (electron/js2c/browser_init.js:161:7486)
    at Object.failListener (electron/js2c/browser_init.js:161:7699)
    at Object.emit (events.js:376:20)

I couldn't find any related topics, any help?

Tollman answered 18/10, 2021 at 18:58 Comment(0)
D
18

Cypress requires the ability to run its GUI. Depending on your Windows version, you likely need some additional configuration in order to run GUI applications in WSL:

  • For all Windows releases, make sure you install the required dependencies:

    apt-get install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb
    

    This may have been done for you depending on how you installed Cypress. I used the npm directions in the Cypress doc.

  • Windows 11 includes the WSLg feature by default, which allows you to run GUI applications directly on Windows. If you upgraded from Windows 10 to Windows 11, run wsl --update to make sure you have the latest WSL version with WSLg.

    Also make sure, if you've attempted to run an X server on an older release (like in the next suggestion), that you remove any manual configuration of DISPLAY in your startup files (e.g. ~/.bashrc, etc.).

  • For Windows 10, you will need to do some additional configuration. There are really two ways to do this, but it's a better topic for Super User (since it isn't directly related to programming), so I'm going to point you to this Super User question for some details. Either answer there is fine. While I'm partial to my solution, most people opt for running a third-party X server as in harrymc's answer there.

Just to make sure there weren't any "hidden tricks" needed to get Cypress running, I can confirm that I was able to successfully ./node_modules/.bin/cypress open using the Cypress instructions and my xrdp technique from the Super User answer.

Deannadeanne answered 18/10, 2021 at 22:37 Comment(2)
Cypress can fine run without a GUI. That's cypress run which the OP mentioned. For ´cypress open`, the answer holds.Adaptive
Updating the version of WSL did the job for me, thanks!Ungrudging
S
9

This error started popping up in our Azure Cypress pipeline as well. However, it started happening when we migrated to Cypress 8.6.0, which was the most recent version of Cypress when this was asked. Reverting back to 8.4.0 solved our problem.

Submediant answered 5/11, 2021 at 20:30 Comment(1)
This started to pop up on Github Actions (AFAIK the same technology as Azure Pipelines), too. Here is a Github issue tracking this problem.Thebaine
L
6

I had little luck looking at various posts, being behind a VPN sometimes and a corp firewall seemed to be a major problem.

I'd constantly get errors like:

[14874:0408/102328.150664:ERROR:bus.cc(392)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[14874:0408/102328.150745:ERROR:bus.cc(392)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[15032:0408/102328.255402:ERROR:gpu_init.cc(453)] Passthrough is not supported, GL is swiftshader, ANGLE is
[14874:0408/102328.321306:ERROR:bus.cc(392)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[14874:0408/102328.331513:ERROR:bus.cc(392)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[14874:0408/102402.013363:ERROR:connection.cc(66)] X connection error received.
[15032:0408/102402.014034:ERROR:connection.cc(66)] X connection error received.
[15032:0408/102402.014064:ERROR:connection.cc(66)] X connection error received.

I found that the issue was WSL2 needs the display to be set to the IP address of the host Windows machine. This reads weird, but if you're unfamiliar with WSL2, it has its own IP address and subnet; thus you need to tell it to use the IP of the display which is not its own.

I documented the full process here: https://gist.github.com/pjobson/6b9fb926c59f58aa73d4efa10fe13654

My steps were:

  1. Install Dependencies
  2. Install certs for my corp firewall
  3. Install node
  4. Install vcxsrv
  5. Set the $DISPLAY
  6. Setup DBUS
  7. Start X-Server
  8. Edit Windows Firewall
  9. Install Cypress
Lalia answered 8/4, 2022 at 14:34 Comment(0)
R
5

Cypress troubleshooting page indicates you can ignore these errors. I am now unsure if this is the error or a red herring.

https://docs.cypress.io/guides/references/troubleshooting#Run-the-Cypress-app-by-itself

Note: verbose Electron logging might show warnings that still allow Cypress to work normally. For example, the Cypress Test Runner opens normally despite the scary output below:[475:0617/150421.326986:ERROR:bus.cc(395)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory [475:0617/150425.061526:ERROR:bus.cc(395)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix") [475:0617/150425.079819:ERROR:bus.cc(395)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")

I have this error on a timed out cypress run, but also on successful runs. This leads me to believe I can ignore it.

Reclusion answered 15/11, 2021 at 5:41 Comment(0)
D
1

I was facing this error today, updating cypress fixed the error for me

npm install cypress@latest

Dilapidated answered 11/10, 2023 at 15:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.