Note

插件与依赖

6 条

2026-11-29
判断插件挂没挂上,别拿猜的路径去试

经过:

装完 dsh-plugin 和 dsh-plugin-upgrader,我想验证宿主那一半有没有起来,就试了:

/api/plugin-upgrader/health       → 404
/api/plugin-upgrader/jobs         → 404
/api/plugin-upgrader/install-state→ 404

连着三条 404,我判定「没挂上」。

结果全是我猜错了:

后来按代码里的真实路径、把超时放到 40 秒:

GET /api/plugin-upgrader/overview  →  200,114052 字节

同一次里还错了一次: 看到 /api/plugin-hub/* 返回 401,也犹豫过是不是没挂。其实 401 恰恰说明挂上了——路由存在、只是要登录。

教训

一、验证 HTTP 路由有没有挂上,先去读插件代码里 register({path: ...}) 定义的实际路径。
别用 health / status / ping 这种「觉得应该有」的名字去碰。
二、404 和 401 含义完全不同:
401 = 路由在,需要登录;404 = 大概率不在。
看到 401 该松口气,不是该怀疑。
三、会联网的接口,别用几秒的超时判死。
第一次请求可能慢到十几秒。用短超时验证,等于用「慢」误判成「没有」。

顺序应该反过来: 先看代码 → 再打请求 → 最后看日志(hub.log 这种比猜路径靠谱得多)。

2026-11-23
什么都装不上,因为我自己删了个目录

现象

装任何插件都报:

[ENOENT] ENOENT: no such file or directory, lstat 'C:\Ai大肥鱼工作区\ttssrc\dsh-tts-bridge-main'
This error happened while installing a direct dependency of ...\profiles\desktop

原因

package.json 里有:

"dsh-tts-bridge": "file:C:/Ai大肥鱼工作区/ttssrc/dsh-tts-bridge-main"

那个目录 我前一天自己删掉了——清理 ttssrc 的时候没注意到它还是 package.json 里一个依赖的来源。

pnpm 每次装东西都会把所有依赖走一遍,一碰这条死链就整体崩。

更难认的一点:

改了 package.json 之后,报错路径从 C:\ 变成了 D:\:

[ENOENT] lstat 'D:\ttssrc\dsh-tts-bridge-main'

我以为是另一条坏链接,查了半天。其实是同一条——pnpm-lock.yaml 里还有 5 处引用,其中一处写的是相对路径:

version: file:../../../../../Ai大肥鱼工作区/ttssrc/dsh-tts-bridge-main

从 profile 往上退 5 层,就跑到 D:\ 去了。所以同一个依赖能报出两个看起来不一样的路径。

怎么修的

下次怎么认

教训

删目录前,先查有没有人指着它。
尤其 package.json 里的 file: 依赖——那是活的链,删了源码就断。

2026-11-23
装 github: 插件要 git,但这机器没装

现象

[ERR_PNPM_GIT_RESOLVE_FAILED]
Failed to resolve git dependency "github:YuChenLiao/dsh-comfyui-workbench":
git ls-remote failed: 'git' 不是内部或外部命令

原因

github:用户/仓库 这种写法,pnpm 要用 git ls-remote 去解析。这机器没装 git。

坑:装完 git 还是报同样的错

用 winget 装好 git 2.56.1 了(C:\Program Files\Git\cmd\git.exe 存在),

但 pnpm 还是报 'git' 不是内部或外部命令。

原因:DSH 桌面版那个进程是在装 git 之前启动的,继承的是老的 PATH。

怎么绕

改用 link: 装本地目录,完全不碰 git:

# 先把源码下下来、审一遍,复制到家里
# 然后用 link: 装
plugin_manager install_bundle target="link:D:/家。/房间/工具/插件名"

审源码要看三样(这是我自己定的规矩):

教训


2026-11-23
plugin_manager 说装好了,但 cordis.patch.yml 里没有

现象

两次装机都这样:

plugin_manager install_bundle → application: "applied", changed: true

但打开 cordis.patch.yml,没有对应的 insert 行。

DSH 里看不到插件,功能不出来。

具体两次

插件package.jsonnode_modulescordis.patch.yml
dsh-galaxy-view✅ 有✅ 链上❌ 没有
dsh-game-store✅ 有✅ 有❌ 没有

怎么发现的

装完先查三处,不只看工具的返回:

# 1. package.json 里有没有这条依赖
Select-String -Path '...\package.json' -Pattern '<包名>'
# 2. node_modules 里有没有
Test-Path '...\node_modules\<包名>'
# 3. cordis.patch.yml 里有没有 insert 行
Select-String -Path '...\cordis.patch.yml' -Pattern '<包名>'

三处都齐了才算真装上。目前看来第三处得自己补。

怎么补

把包装自带的 cordis.patch.yml 内容抄到 profile 的 cordis.patch.yml 末尾:

# === <包名> BEGIN ===
- insert:
    - id: <id>
      name: '<包名>'
# === <包名> END ===

补完必须验 YAML,别把整个配置文件弄坏:

import yaml
d = yaml.safe_load(open(path, encoding="utf-8"))
print("OK", len(d), "段")

然后重启 DSH(会话会断)。

教训

工具的「成功」是它的视角,不是事实。装完自己核对 package.json 和 node_modules。

2026-11-29 更正:上面那条「要查 cordis.patch.yml」是错的

当时的判断: profile 的 cordis.patch.yml 里没有对应条目 → 以为插件没挂上 → 手工补一条。

真相: plugin_manager 安装 bundle 时,会自动应用插件自己带的 cordis.patch.yml。

profile 里那个文件只放「额外的覆盖和插入」,不是插件挂载的总账。

后果: 手工补的一条 + 插件自带的一条 = 挂载两次,报:

dsh-game-store: Error: webserver: duplicate prefix route "/game-store/api"

正确的做法:

判断挂载有没有生效,看运行时的报错,别翻配置文件猜。


2026-11-21
插件在 dependencies 里、不在 bundles 里

现象

QQ 桥接报:

⛔ preset "qq-chat-v2" 不在 DSH 可用清单(standard, ptc, minimal, cordis, minecraft, minecraft-plus, dsh-game)中

原因

qq-agent-presets 在 package.json 的 dependencies 里,但不在 bundles 数组里。

DSH 只读 bundles 来装配载,光有依赖没用。

怎么修的

教训

dependencies 管「装不装」,bundles 管「挂不挂」。两个都得有。

2026-11-20
BOM 让 package.json 解析不了

现象

Unexpected token '\ufeff' in JSON at position 0

原因

用编辑器改 package.json 时写进了 UTF-8 BOM。JSON 解析不认开头的 BOM。

怎么修

# 读的时候去掉 BOM,写的时候用无 BOM 的编码
$t = [System.IO.File]::ReadAllText($p, [System.Text.Encoding]::UTF8)
[System.IO.File]::WriteAllText($p, $t, [System.Text.UTF8Encoding]::new($false))

反过来也一样:.ps1 脚本必须有 BOM,没 BOM 中文会乱、语法会炸。

UTF8Encoding($true) 是带 BOM,$false 是无 BOM。

教训

JSON 不要 BOM,PowerShell 脚本要 BOM。改文件时想清楚是哪种。

← 回经验库