首页 > 解决方案 > 在 WSL 上运行赛普拉斯

问题描述

我正在尝试使用 Ubuntu 在 WSL 上运行 cypress,这就是我得到的:

$ 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)

我找不到任何相关主题,有什么帮助吗?

标签: javascriptcypresswindows-subsystem-for-linuxyarn-v2

解决方案


赛普拉斯需要能够运行其 GUI。根据您的 Windows 版本,您可能需要一些额外的配置才能在 WSL 中运行 GUI 应用程序:

  • 对于所有 Windows 版本,请确保安装所需的依赖项

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

    这可能已为您完成,具体取决于您安装赛普拉斯的方式。我使用了npm赛普拉斯文档中的说明。

  • Windows 11 默认包含 WSLg 功能,允许您直接在 Windows 上运行 GUI 应用程序。如果您从 Windows 10 升级到 Windows 11,请运行wsl --update以确保您拥有带有 WSLg 的最新 WSL 版本。

    还要确保,如果您尝试在旧版本上运行 X 服务器(如在下一个建议中),请确保删除DISPLAY启动文件中的任何手动配置(例如~/.bashrc,等等)。

  • 对于 Windows 10,您需要进行一些额外的配置。确实有两种方法可以做到这一点,但对于超级用户来说这是一个更好的主题(因为它与编程没有直接关系),所以我将向您指出这个超级用户问题以了解一些细节。任何一个答案都可以。虽然我偏爱我的解决方案,但大多数人选择运行第三方 X 服务器,就像 harrymc 在那里的回答一样。

只是为了确保赛普拉斯运行不需要任何“隐藏技巧”,我可以确认我能够成功./node_modules/.bin/cypress open使用赛普拉斯指令xrdp超级用户回答中的技术。


推荐阅读