Skip to content

[Bug] README 方式一 dsh plugin add "github:...#main&path:..." 在 Windows 上必失败(cmd 拆解 & → ERR_PNPM_INVALID_DEPENDENCY_NAME) #20

Description

@ErrorLst

环境

  • Windows(win32)
  • @deepseek-ai/dsh 0.1.0-rc.7,node v22.23.1,pnpm 11.7.0

复现

按 README「方式一:git 源直接安装(推荐)」执行:

dsh plugin --profile web add "github:vlln/plugin-registry#main&path:/packages/plugin/console"

实际输出(100% 复现):

dependencies:
+ plugin-registry#main github:vlln/plugin-registry#main

[ERR_PNPM_INVALID_DEPENDENCY_NAME] Refusing to place a dependency under C:\Users\zhoujin\.dsh\profiles\web\node_modules with the invalid alias "plugin-registry#main"
Progress: resolved 6, reused 3, downloaded 1, added 0

期望:与 macOS/Linux 一致,安装成功并把 @vlln/plugin-console 登记进 dsh.profile.bundles

根因(Windows 专属,链路已实测验证)

  1. dsh plugin 在 win32 上用 spawnSync("pnpm", args, { shell: true }) 转发参数(dsh lib/plugin-9h8shc4d.js:108),走 cmd.exe;& 是 cmd 的命令分隔符 → 参数被拆成两条命令:pnpm 只收到 github:vlln/plugin-registry#mainpath:/packages/plugin/console 作为第二条命令执行——恰好命中 cmd 内置 path 命令,静默无报错,终端看不出来。
  2. 即使用 ^& 转义也救不回:npm 生成的 pnpm.cmd 垫片内部 %* 二次展开时 & 再次成为分隔符(已实测确认)。
  3. &path: 丢失后 pnpm 解析仓库根目录——本仓库根目录没有 package.json,pnpm 按 bareSpecifier.split('/').pop() 合成包名 plugin-registry#main(version 0.0.0,已残留进 lockfile),链接 node_modules 时 # 非法 → 上述报错。

影响

  • README 方式一对 Windows 用户不可用,且失败会污染 pnpm-lock.yaml(残留 plugin-registry#main 条目)。
  • 根因在 dsh CLI 的 Windows 转发,但建议本仓库先文档兜底。

临时方案(Windows 用户)

  • 不带 & 的等价形式(pnpm 原生 #path:,取 main 的 HEAD,与 profile 里 @openviking/dsh-memory-plugin 同款语法):
dsh plugin --profile web add "github:vlln/plugin-registry#path:/packages/plugin/console"
  • 需要显式钉 main 时(绕开 dsh 转发,直接 pnpm + dsh 收尾登记):
cd $HOME\.dsh\profiles\web; pnpm add "github:vlln/plugin-registry#main&path:/packages/plugin/console"; dsh plugin --profile web install

建议

  1. README「方式一」补充 Windows 说明或改为跨平台可用写法,避免更多 Windows 用户踩坑;
  2. 同步向官方 dsh(deepseek-ai/deepseek-harness,issues 已关闭,需走 Discussion)反馈 win32 shell:true 转发缺陷。

关联:#4(同是 Windows 下 pnpm 执行问题)。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions