javascript - 在 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)
我找不到任何相关主题,有什么帮助吗?
解决方案
赛普拉斯需要能够运行其 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
超级用户回答中的技术。
推荐阅读
- oracle - 错误:ORA-12545:连接失败,因为目标主机或对象不存在
- javascript - 有没有办法防止链接打开但仍然被索引?
- or-tools - 运行多个 Google OR Solver (CBC) 实例导致找不到解决方案 (C++)
- c++ - 椭圆问题(旋转):检测到任何点的位置不正确
- java - Android sqlite 数据库 - 如何在滚动结束时显示添加“加载更多项目”的列表视图
- python - 曼德布罗集在 Python 中
- python - Python字典以字母升序对列表进行排序,仅过滤掉80以上的学生分数
- scala - 如何使用来自spray-json的JsonFormat自定义序列化程序序列化作为案例类一部分的akka“actorRef”?
- java - Drools 7 - 从数据库加载规则
- r - 查找与网格单元相交的 sf 多边形的总数