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
[Windows] 宿主注入的 ELECTRON_RUN_AS_NODE=1 导致「打开方式」中的 Electron 编辑器条目启动失败
#8582
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.
DSH Bug Report —「打开方式」中 Electron 编辑器启动失败
Summary
Windows 桌面端会话标题右侧的「打开方式」菜单里,除文件管理器外的所有条目都无法启动,弹出「打开失败,请重试」(
path.openError)。根因:宿主进程携带
ELECTRON_RUN_AS_NODE=1,而dsh-host-open-in-app直接以execFile启动基于 Electron 的 GUI 程序时未清除该变量。被启动的程序因此以 Node 模式运行,把目标路径当作 JS 模块加载而失败,退出码为 1,被runNativeCommand判定为失败。预期同样影响所有以 Electron 实现的条目(VS Code、VS Code Insiders、Cursor、Windsurf、GitHub Desktop 等;仅 VS Code 已实测,其余为推断)。文件管理器条目走 ShellExecute,不受影响。
Reproduction
环境:Windows 11,官方 DSH 桌面端,VS Code(User 安装,非默认路径)。
最小复现(在 DSH 提供的终端,或任何继承宿主环境的进程中):
等价的最小 Node 复现(与 open-in-app 的启动路径一致,无 shell):
删除
ELECTRON_RUN_AS_NODE后再执行同一调用,Code.exe进程数从 0 变为 10+,VS Code 正常打开。Current behavior
菜单弹出「打开失败,请重试」。
Code.exe --version→ 退出码 0,但 stdout 为v24.18.0(Node 版本号,非 VS Code 版本)Code.exe <workspace>→ 退出码 1,stderr:{ kind: "shell-open" },不 spawnCode.exe;且其退出码 1 被按「已转交」处理。已排除的原因:
Code.exe。HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Code.exe的(Default)正确指向实际的Code.exe且文件存在;installRecord使用displayNamePrefix前缀匹配,卸载记录Microsoft Visual Studio Code (User)亦能命中。默认路径%LOCALAPPDATA%\Programs\Microsoft VS Code\Code.exe与%ProgramFiles%\Microsoft VS Code\Code.exe均不存在,但前两个来源已足够。dependencies为空,未安装任何第三方插件。Code.exe立即正常工作。Expected behavior
选择「VS Code」后,应在 VS Code 中打开当前工作区。
Environment
DeepSeek Harness.exe,产品版本0.2.0-rc.2,更新通道nightlyhttps://download.deepseek.com/dsh-desk/feeds/win-x64/"D:\DSH\DeepSeek Harness.exe" --expose-internals ...\dsh-desktop-host\lib\index.js ...ELECTRON_RUN_AS_NODE=1;User 级与 Machine 级环境变量均为空 —— 由宿主自行注入1.132.1,User 安装,位于非默认路径@deepseek-ai/dsh-host-open-in-app、@deepseek-ai/dsh-native-command修复方向
启动外部 GUI 程序时(
runNativeCommand(..., 'visible'),或dsh-host-open-in-app的启动层),应清除从宿主继承的 Electron 专用环境变量,至少:宿主自身必须以 Electron 的 Node 模式运行(命令行中的
--expose-internals .../dsh-desktop-host/lib/index.js依赖该变量),因此它会污染所有下游 spawn。启动用户桌面上的 GUI 程序时,应当视为"进入用户的桌面环境",而不是继续沿用宿主的运行时环境。仅影响 Windows:macOS 走
open -a、Linux 走 desktop entry / CLI,均不直接 spawn Electron 二进制。All reactions