Repository navigation
Replies: 3 comments
|
Confirmed on current Root cause matches the report. Patch — branch: https://github.com/aturzone/deepseek-harness/tree/fix/windows-alias-executable, commit
Evidence. New spec injects a Design note: I kept the helper local to |
|
While verifying this patch on the current checkout, I found and fixed a test-isolation defect in the same package (second commit
This is test-only and not part of the shell-menu defect; it is included because it was blocking clean verification of the resolver change. |
|
补充一条来自另一套 MSIX 包的数据,顺便确认最新代码里仍未修复: 环境
别名行为(%LOCALAPPDATA%\Microsoft\WindowsApps\pwsh.exe,IO_REPARSE_TAG_APPEXECLINK 0x8000001B)
现象
代码现状(已核对)
TL;DR: Same stat()/EACCES behavior reproduces with Microsoft.PowerShellPreview 7.7 (MSIX). Latest master fcc0ad4 / v0.2.2-rc.1 still uses stat() + access() in subprocess-local.resolveExecutable; the lstat fix is not merged yet. +1 for landing it (also fixes #11975). |
Uh oh!
There was an error while loading. Please reload this page.
Microsoft Store 版 PowerShell 7 无法出现在终端 shell 菜单(App Execution Alias 的
stat()抛EACCES)环境
0.2.1-rc.5(nightly 通道)%LOCALAPPDATA%\Microsoft\WindowsApps\pwsh.exe(85 字节的 App Execution Alias)C:\Program Files\WindowsApps\Microsoft.PowerShell_7.6.9.0_x64__8wekyb3d8bbwe\pwsh.exe概要
右侧栏终端的 shell 菜单只列出探测通过的 shell——通常是
cmd.exe与powershell.exe——始终没有pwsh.exe。而pwsh在PATH上,cmd与 PowerShell 都能解析到,从资源管理器或通过 DSH 自己的 shell 工具直接启动也正常。shellCandidates默认值已经是["zsh", "bash", "fish", "pwsh", "powershell", "cmd"],也就是说只要装了pwsh就应当在菜单中出现;实际失败是静默的,界面上没有任何错误提示。复现步骤
where pwsh→%LOCALAPPDATA%\Microsoft\WindowsApps\pwsh.exe;pwsh -NoLogo -Command '$PSVersionTable.PSVersion'→7.6.9。cmd.exe和powershell.exe(若系统中存在 WSL 的bash.exe存根也会出现)。pwsh.exe缺失。预期:
pwsh.exe出现在列表中,可选中,并可作为新终端记住的 shell。实际:
pwsh.exe始终不出现,也没有任何错误提示。根因
两个包对“Windows App Execution Alias 算不算可执行文件”的判断不一致。
@deepseek-ai/dsh-subprocess-local的resolveExecutable()用fs.stat()校验候选,并把任何异常都当作“继续找下一个”:在 Windows 上,
%LOCALAPPDATA%\Microsoft\WindowsApps下的 App Execution Alias 是一个重解析点:lstat()显示为符号链接,stat()会跟随进入C:\Program Files\WindowsApps\...并抛出EACCES。catch 吞掉该错误,循环耗尽后,调用方收到的是“未找到”。@deepseek-ai/dsh-api-terminal-controller的discoverShells()只把SubprocessExecutableNotFoundError当作“未安装”跳过,其他异常继续上抛:于是
pwsh候选从菜单中静默消失。值得注意的是,DSH 自己的可执行文件查找实现(
which工具中的isExecutable())已经明确记录并处理了这一 Windows 行为:终端这条链路没有复用该判定,因此 Store 安装的 shell 对选择器不可见。
最小复现(纯 Node,无需 DSH)
目标文件本身可
stat、可执行,只有沿别名跟随失败。影响面
pwsh,尽管 DSH 默认就把pwsh列为候选。WindowsApps别名(如winget.exe、python.exe、notepad.exe)同样返回EACCES。临时规避(当前可用)
在 profile 补丁中补上解析后的真实路径。注意
config是整体替换、不会深合并,因此需要完整重写候选列表:验证结果:加入该条目后
pwsh可被发现(绝对路径能通过stat()/access()),并以 PowerShell 7.6.9 启动。缺点是 Store 包升级会改变带版本号的目录名,该写法需要持续维护。建议修复
subprocess-local.resolveExecutable()中与which工具保持一致——win32 上把stat()返回的EACCES视为“存在且可执行”并返回该候选(同时跳过access(X_OK),它在 Windows 上无法区分是否可执行)。可将特例限定为.exe候选或%LOCALAPPDATA%\Microsoft\WindowsApps下的路径,把影响范围控制住。discoverShells()通过共享的whichCommand()解析候选,而不是维护第二套更弱的实现。lstat返回符号链接、stat抛EACCES),即可同时覆盖解析器与发现流程,无需在 CI 中安装 MSIX。补充验证
pwsh -NoLogo -NoProfile -Command "$PSVersionTable.PSVersion"→7.6.9(直接使用包内路径)。WindowsApps别名都能复现相同的stat行为,说明这是 MSIX / App Execution Alias 的通用行为,而非 PowerShell 包自身的问题。All reactions