You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WSL2中Cypress图形界面启动失败问题求助

在WSL2中启动Cypress图形界面报错的解决方案

问题详情

在WSL2中配置Cypress后:

  • 无GUI模式执行npx cypress run运行测试完全正常
  • 启动带X-server的图形界面时,执行命令CYPRESS_BASE_URL=http://localhost:8000 npx cypress open --config-file cypress.json,出现以下错误:

[4735:0418/164505.014625:ERROR:gpu_init.cc(440)] Passthrough is not supported, GL is swiftshader
[4563:0418/164506.171450:ERROR:bus.cc(393)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[4563:0418/164506.187367:ERROR:bus.cc(393)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")

修复步骤

1. 处理GPU警告(非致命)

Passthrough is not supported, GL is swiftshader是WSL2对GPU硬件加速的限制导致的警告,不影响Cypress正常运行,可直接忽略。若要消除该警告,启动时添加禁用GPU加速的环境变量:

CYPRESS_GPU_ACCELERATION=off CYPRESS_BASE_URL=http://localhost:8000 npx cypress open --config-file cypress.json

2. 解决DBus连接错误

Failed to connect to the bus是WSL2中DBus服务未正确配置导致,按以下操作修复:

  • 启动DBus服务:
    sudo service dbus start
    
  • 若启动失败,手动设置DBus环境变量:
    export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus
    
  • 重新执行Cypress启动命令即可。

3. 验证X-server配置

确保Windows端X-server(如VcXsrv、X410)已正常启动,且WSL2的DISPLAY变量配置正确:

  • 检查DISPLAY变量:
    echo $DISPLAY
    
  • 若变量为空,手动设置:
    export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0
    

内容的提问来源于stack exchange,提问作者user2953989

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 08:02:14