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

Debian服务器VS Code在Windows远程登录时无法打开窗口

Debian服务器上VS Code在Windows通过Putty+Xming无法打开窗口的问题

问题描述

我在Debian服务器上安装了VS Code。从Mac登录服务器执行code test.txt时,VS Code窗口能正常打开并加载文件;但任何用户从Windows通过Putty和Xming登录时,执行同样命令无法打开窗口,其他程序却能正常启动窗口。

详细日志

执行code code.log --verbose得到以下输出:

[1005271:0913/112607.047939:警告:bluez_dbus_manager.cc(247)] 未找到Floss管理器,无法设置Floss启用/禁用状态。
[主进程 2023-09-13T09:26:07.128Z] [文件监视器(node.js)] 请求开始监视: /home/heinze/.config/Code/User (排除: <无>, 包含: <全部>),/home/heinze/.config/Code/User/settings.json (排除: <无>, 包含: <全部>)
[主进程 2023-09-13T09:26:07.137Z] 启动VS Code
[主进程 2023-09-13T09:26:07.137Z] 路径: /usr/share/code/resources/app
[主进程 2023-09-13T09:26:07.137Z] 参数: {
  _: [ '/home/heinze/code.log' ],
  diff: false,
  merge: false,
  add: false,
  goto: false,
  'new-window': false,
  'reuse-window': false,
  wait: false,
  help: false,
  'list-extensions': false,
  'show-versions': false,
  'pre-release': false,
  version: false,
  verbose: true,
  status: false,
  'prof-startup': false,
  'no-cached-data': false,
  'prof-v8-extensions': false,
  'disable-extensions': false,
  'disable-gpu': false,
  'disable-chromium-sandbox': false,
  'ms-enable-electron-run-as-node': false,
  telemetry: false,
  debugRenderer: false,
  'enable-smoke-test-driver': false,
  logExtensionHostCommunication: false,
  'skip-release-notes': false,
  'skip-welcome': false,
  'disable-telemetry': false,
  'disable-updates': false,
  'disable-keytar': false,
  'disable-workspace-trust': false,
  'disable-crash-reporter': false,
  'crash-reporter-id': 'dcb7898e-cbb1-4a44-a06a-ad4b7606663d',
  'skip-add-to-recently-opened': false,
  'unity-launch': false,
  'open-url': false,
  'file-write': false,
  'file-chmod': false,
  force: false,
  'do-not-sync': false,
  trace: false,
  'force-user-env': false,
  'force-disable-user-env': false,
  'open-devtools': false,
  'disable-gpu-sandbox': false,
  '__enable-file-policy': false,
  'enable-coi': false,
  'no-proxy-server': false,
  'no-sandbox': false,
  nolazy: false,
  'force-renderer-accessibility': false,
  'ignore-certificate-errors': false,
  'allow-insecure-localhost': false,
  'disable-dev-shm-usage': false,
  'profile-temp': false,
  logsPath: '/home/heinze/.config/Code/logs/20230913T112607'
}
[主进程 2023-09-13T09:26:07.138Z] 解析机器标识符...
[主进程 2023-09-13T09:26:07.138Z] 已解析机器标识符: d1a7f5f6babb7f599fa020d9721d9495b2b0102714c7dc8672f5253267742284
[主进程 2023-09-13T09:26:07.138Z] 主进程->共享进程#连接
[主进程 2023-09-13T09:26:07.140Z] [文件监视器(node.js)] 已开始监视: '/home/heinze/.config/Code/User'
[主进程 2023-09-13T09:26:07.142Z] [文件监视器(node.js)] 已开始监视: '/home/heinze/.config/Code/User/settings.json'
[主进程 2023-09-13T09:26:07.143Z] 存储主服务: 创建应用存储
[主进程 2023-09-13T09:26:07.144Z] ElectronURL监听器: 等待窗口准备好处理URL...
[主进程 2023-09-13T09:26:07.144Z] 生命周期(主进程): 阶段变更(值: 2)
[主进程 2023-09-13T09:26:07.144Z] 窗口管理器#打开
[主进程 2023-09-13T09:26:07.145Z] 窗口管理器#打开待打开路径 [
  {
    fileUri: c {
      scheme: 'file',
      authority: '',
      path: '/home/heinze/code.log',
      query: '',
      fragment: '',
      _formatted: null,
      _fsPath: null
    },
    type: 1,
    exists: true,
    options: { selection: undefined }
  }
]
[主进程 2023-09-13T09:26:07.146Z] IPC对象URL: 已注册新通道 vscode:3b6218ed-c4a0-465a-b2f4-9a3310f50c8e.
[主进程 2023-09-13T09:26:07.146Z] 窗口#验证窗口状态: 在1个显示器上验证窗口状态 { mode: 1, x: 1337, y: 294, width: 1024, height: 768 }
[主进程 2023-09-13T09:26:07.146Z] 窗口#验证窗口状态: 1个显示器工作区域 { x: 0, y: 0, width: 2560, height: 1440 }
[主进程 2023-09-13T09:26:07.146Z] 窗口#构造函数: 使用窗口状态 { mode: 1, x: 1337, y: 294, width: 1024, height: 768 }
[主进程 2023-09-13T09:26:07.180Z] 窗口#加载: 尝试加载窗口(编号: 1)
[主进程 2023-09-13T09:26:07.184Z] 窗口管理器#打开已使用窗口数 1 (待打开工作区: 0, 待打开文件夹: 0, 待恢复空窗口: 0, 待打开空窗口: 0)
[主进程 2023-09-13T09:26:07.184Z] 生命周期(主进程): 阶段变更(值: 3)
[主进程 2023-09-13T09:26:07.184Z] resolveShellEnv(): 已跳过(VSCODE_CLI已设置)
[主进程 2023-09-13T09:26:07.184Z] 更新#设置状态 idle
[1005271:0913/112608.015206:警告:bus.cc(644)] Bus::SendWithReplyAndBlock 处理消息耗时1001ms: type=method_call, path=/org/freedesktop/DBus, interface=org.freedesktop.DBus, member=StartServiceByName
[1005271:0913/112608.015250:错误:object_proxy.cc(590)] 调用方法失败: org.freedesktop.DBus.StartServiceByName: object_path= /org/freedesktop/DBus: org.freedesktop.DBus.Error.NoReply: 未收到响应。可能原因包括: 远程应用未发送响应、消息总线安全策略阻止了响应、响应超时或网络连接中断。
[主进程 2023-09-13T09:26:11.351Z] 生命周期(主进程): 阶段变更(值: 4)
[主进程 2023-09-13T09:26:13.390Z] IPC对象URL: 已移除通道 vscode:3b6218ed-c4a0-465a-b2f4-9a3310f50c8e.
[主进程 2023-09-13T09:26:13.391Z] 生命周期#窗口.on('closed') - 窗口编号1
[主进程 2023-09-13T09:26:13.391Z] 生命周期#onWillShutdown.fire()
[主进程 2023-09-13T09:26:13.391Z] 生命周期#onWillShutdown - 开始 'instanceLockfile'
[主进程 2023-09-13T09:26:13.392Z] 存储主服务#onWillShutdown()
[主进程 2023-09-13T09:26:13.392Z] 生命周期#onWillShutdown - 开始 'applicationStorage'
[主进程 2023-09-13T09:26:13.392Z] 生命周期#onWillShutdown - 开始 'extHostStarter'
[主进程 2023-09-13T09:26:13.392Z] 生命周期#onWillShutdown - 结束 'extHostStarter'
[主进程 2023-09-13T09:26:13.392Z] 生命周期#app.on(window-all-closed)
[主进程 2023-09-13T09:26:13.392Z] 生命周期#app.on(before-quit)
[主进程 2023-09-13T09:26:13.392Z] 生命周期#onBeforeShutdown.fire()
[主进程 2023-09-13T09:26:13.392Z] [窗口状态处理器] onBeforeShutdown {
  lastActiveWindow: undefined,
  lastPluginDevelopmentHostWindow: undefined,
  openedWindows: []
}
[主进程 2023-09-13T09:26:13.392Z] 生命周期#app.on(will-quit) - 开始

解决方案

  • 检查Xming与Putty的X转发配置
    确保Xming已启动,Putty中Connection -> SSH -> X11选项勾选Enable X11 forwarding,X display location设为:0.0。登录服务器后执行echo $DISPLAY,确认输出为localhost:10.0或类似有效地址。

  • 添加VS Code兼容启动参数
    Electron应用在X转发环境下可能存在GPU或沙箱兼容性问题,执行以下命令启动:

    code --disable-gpu --no-sandbox test.txt
    
  • 规避DBus无响应问题
    日志中出现DBus调用失败错误,可通过设置环境变量跳过DBus依赖:

    DBUS_SESSION_BUS_ADDRESS=/dev/null code test.txt
    

    也可结合GPU禁用参数:

    DBUS_SESSION_BUS_ADDRESS=/dev/null code --disable-gpu test.txt
    
  • 验证X转发基础功能
    先运行xeyes或xterm等简单X应用,确认X转发是否正常。如果这些程序能显示窗口,说明X环境配置无问题,问题集中在VS Code本身。

  • 重置VS Code用户配置
    若用户配置存在冲突,可备份并重置配置:

    mv ~/.config/Code ~/.config/Code.bak
    code test.txt
    

    若窗口能正常打开,再逐步恢复配置文件排查具体冲突项。

内容的提问来源于stack exchange,提问作者M. Heinze

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.10 21:10:54