You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug][Desktop] Windows Open In → VS Code 打不开(502 launch-failed):继承的 ELECTRON_RUN_AS_NODE 让编辑器以 Node 模式启动
#13436
On DSH Desktop for Windows, the session header's Open In… → VS Code does nothing: the button flashes red for ~2 s and no window appears. Detection is fine — the Host resolves VS Code through HKCU App Paths — but the launch is not: the desktop shell runs the Host with ELECTRON_RUN_AS_NODE=1, launchDetachedApp passes the credential-scrubbed parent environment through unchanged, so Code.exe <workspace> starts in Node mode, treats the workspace directory as a script entry, exits with code 1 inside the 1 s watch window, and POST /open-in-app/open answers 502 launch-failed. All Electron-based editors in the catalog are affected (VS Code, VS Code Insiders, Cursor, Windsurf); GitHub Desktop is not, because its adapter sets the variable deliberately. This is already fixed on master by a8ea5fcf (2026-11-07), but that commit is absent from the source at tags dsh-v0.2.2-rc.1, rc.2 and rc.3, so every current release still ships the bug.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
English summary
On DSH Desktop for Windows, the session header's Open In… → VS Code does nothing: the button flashes red for ~2 s and no window appears. Detection is fine — the Host resolves VS Code through HKCU
App Paths— but the launch is not: the desktop shell runs the Host withELECTRON_RUN_AS_NODE=1,launchDetachedApppasses the credential-scrubbed parent environment through unchanged, soCode.exe <workspace>starts in Node mode, treats the workspace directory as a script entry, exits with code 1 inside the 1 s watch window, andPOST /open-in-app/openanswers502 launch-failed. All Electron-based editors in the catalog are affected (VS Code, VS Code Insiders, Cursor, Windsurf); GitHub Desktop is not, because its adapter sets the variable deliberately. This is already fixed onmasterbya8ea5fcf(2026-11-07), but that commit is absent from the source at tagsdsh-v0.2.2-rc.1,rc.2andrc.3, so every current release still ships the bug.环境
@deepseek-ai/dsh-desktop0.2.2-rc.1(DeepSeek Harness.exeFileVersion0.2.2-rc.1)%LOCALAPPDATA%\Programs\Microsoft VS Code\Code.exe(HKCUApp Paths已注册)%LOCALAPPDATA%\Programs\DeepSeek Harness\(默认用户级安装)resources/app-update.yml→https://download.deepseek.com/dsh-desk/feeds/win-x64/)desktop/ zh-CN现象
explorer, vscode, gitbash,说明检测与信任链都没问题。复现步骤
D:\harness\system,任意已存在目录均可)。POST /open-in-app/open返回502 {"code":"launch-failed","message":"failed to launch vscode"}。根因
ELECTRON_RUN_AS_NODE=1让 Electron 可执行文件当 node 跑 Host(fuseRunAsNode开启),该变量留在 Host 的process.env,并被所有子进程继承。packages/host/open-in-app/src/resolver.ts中,launchDetachedApp直接使用env: { ...scrubbedParentEnv(), ...options.env };而scrubbedParentEnv()(packages/subprocess/subprocess/src/index.ts:54、73-76)只排除KEY|PASSWORD|SECRET|TOKEN与DSH_*,不含ELECTRON_RUN_AS_NODE。Code.exe "D:\harness\system"以 Node 模式启动,把工作目录当成脚本入口:退出码
1,落在launchWatchMs(1000 ms)观察窗内 →runLaunch归类为failed→packages/host/open-in-app/src/index.ts:296返回502 launch-failed→ 前端phase='error'→ 用户只看到「点一下闪红、什么都没开」。实测证据
调用安装目录里同一份 resolver(
resolveOpenInAppApps+launchResolved,internals.resolveExecutable注入空实现即可,vscode 走app-paths不依赖它):同一 spawn、仅从子进程环境删除
ELECTRON_RUN_AS_NODE→'launched',VS Code 正常打开该目录。与 master 的关系(重点)
a8ea5fcf815132159527e835d1facb3642b6ab7c(2026-11-07,fix(open-in-app): drop inherited ELECTRON_RUN_AS_NODE when launching apps)已在 master 的launchDetachedApp中按name.toUpperCase() !== 'ELECTRON_RUN_AS_NODE'过滤(当前 masterresolver.ts:77-80)。dsh-v0.2.2-rc.1、dsh-v0.2.2-rc.2(11-11)、dsh-v0.2.2-rc.3(11-13)的resolver.ts里都没有这个过滤(只有 GitHub Desktop adapter 自己的env: { ELECTRON_RUN_AS_NODE: '1' })。补充(不影响结论)
code <path>不受此 bug 影响,因为 VS Code 自己的bin\code.cmd就是主动设置ELECTRON_RUN_AS_NODE=1去跑…\resources\app\out\cli.js的 —— 那条路径是把该变量当开关使用。...scrubbedParentEnv(),→...(({ ELECTRON_RUN_AS_NODE: _, ...rest }) => rest)(scrubbedParentEnv()),。因为...options.env在后面展开,GitHub Desktop 显式要求的ELECTRON_RUN_AS_NODE: '1'仍会生效 —— 与 a8ea5fc 的语义一致,修法本身没问题,只是没进发布版。All reactions