【问题标题】:Running Cypress on WSL在 WSL 上运行赛普拉斯
【发布时间】:2021-12-05 19:28:33
【问题描述】:

我正在尝试使用 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)

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

【问题讨论】:

    标签: javascript cypress windows-subsystem-for-linux yarn-v2


    【解决方案1】:

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

    • 对于所有 Windows 版本,请确保安装 required dependencies:

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

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

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

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

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

    为了确保赛普拉斯运行不需要任何“隐藏技巧”,我可以确认我能够使用来自超级用户答案的​​Cypress instructions 和我的xrdp 技术成功地./node_modules/.bin/cypress open .

    【讨论】:

      【解决方案2】:

      我们的 Azure Cypress 管道中也开始出现此错误。然而,当我们迁移到赛普拉斯 8.6.0 时,它开始发生了,当被问及这个问题时,这是赛普拉斯的最新版本。恢复到 8.4.0 解决了我们的问题。

      【讨论】:

      • 这也开始出现在 Github Actions 上(AFAIK 与 Azure Pipelines 技术相同)。 Here 是一个跟踪此问题的 Github 问题。
      【解决方案3】:

      Cypress 故障排除页面表明您可以忽略这些错误。我现在不确定这是错误还是红鲱鱼。

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

      注意:详细的电子日志记录可能会显示仍然允许赛普拉斯正常工作的警告。例如,尽管出现以下可怕的输出,Cypress Test Runner 仍可正常打开:[475:0617/150421.326986:ERROR:bus.cc(395)] 无法连接到总线:无法连接到套接字 /var/run/dbus/ system_bus_socket:没有这样的文件或目录 [475:0617/150425.061526:ERROR:bus.cc(395)] 无法连接到总线:无法解析服务器地址:未知地址类型(有效类型的示例为“tcp”,在 UNIX 上为“unix”) [475:0617/150425.079819:ERROR:bus.cc(395)] 无法连接到总线:无法解析服务器地址:未知地址类型(有效类型的示例为“tcp”,在 UNIX 上为“unix”)

      我在 cypress 运行超时时出现此错误,但在成功运行时也出现此错误。这让我相信我可以忽略它。

      【讨论】:

        猜你喜欢
        • 2020-10-19
        • 2022-09-30
        • 2023-04-04
        • 1970-01-01
        • 2019-12-27
        • 2020-12-23
        • 2023-02-10
        • 1970-01-01
        • 2019-07-29
        相关资源
        最近更新 更多