笔记 by 车东

OpenClaw Telegram /update 升级失败:update-recovery-pending(Package publication journal does not match its installation)与 Node 26.12.1 版本门(2026.10.5→2026.10.7)

· 运维

在 Telegram 发 /update 升 2026.10.7,bot 回复"已提交"但版本没动。日志只有 update.run … status=skipped 和 update-recovery-pending: Package publication journal does not match its installation。清掉 10-19 遗留的孤儿 journal 后,又卡在 Node 版本门(本机 26.10.0 < 2026.10.7 要求的 26.12.1);换成 Node 26.12.1 后升级成功,但 LaunchAgent 被 bootout 没重新拉起,openclaw gateway install --force 恢复。最后 journal 停在 publication-complete,要跑一次 recovery.mjs retire 才算真正收尾——否则下一次 /update 还会被拦。

📌 TLDR

  1. /update 什么都没做。它在准入闸门 assertNoPendingPackageActivation() 就返回了,日志表现为 update.run … status=skipped。闸门的判据是 readPackageActivationContinuation(),只有两种情况放行:
    • journal 不存在 且 <anchor> 与 <anchor>.control 都不存在;
    • 或 isPackageActivationComplete() 成立 —— phase === "anchor-retired" 且有 unlink-helper intent。
  2. 真正拦住它的是设备号漂移,不是 inode。matchesInstallation() 只比对 parentIdentity / journalParentIdentity / journalIdentity 三个 device:inode 字符串。10-19 那份 journal 记的是 16777220:*,APFS 卷重挂后实际是 16777221:*,inode 全对也没用 → inspectRemount() 抛 Package settlement inode or device mapping changed.。openclaw update repair --yes 救不了。
  3. 清掉孤儿 journal 后暴露出第二层:2026.10.7 的 engines 是 >=24.22.1 <25 || >=26.12.1,本机 Node 26.10.0 不满足,package-install 跑 scripts/preinstall-package-manager-warning.mjs exit 1,最终 global-install-failed。--omit=optional 重试同样失败(卡的不是可选依赖)。
  4. 升级成功 ≠ 服务起来。activating 完成后自动重启失败(state-migrated-no-rollback、Gateway did not settle),LaunchAgent 被 bootout 且没有重新 bootstrap。openclaw gateway install --force 一行恢复。
  5. 每次升级后都要看 openclaw update status 的 Package recovery。若是 publication-complete / aborted 而不是 complete,下次 /update 必挂;recovery.mjs repair 是空操作,retire 才有效。

现象

在 Telegram 里发 /update,bot 回得挺痛快,但 openclaw --version 一直是 2026.10.5。

网关日志(/tmp/openclaw/openclaw-YYYY-MM-DD.log)里只有两行关键信息:

13:11:18 update.run completed actor=gateway-client … restartReason=update.run status=skipped
13:12:41 ERROR Update recovery remains pending (update-recovery-pending).
         Package publication journal does not match its installation

openclaw update status 同时给出长期状态:

Package recovery │ Package publication journal does not match its installation
Update           │ available · npm · npm update 2026.10.7

注意 update status 本身会卡住自旋、烧 CPU —— 它每次读 journal 都抛错重试,一度占满一个核。

根因 A:孤儿 package-activation journal

抛错点在 dist/package-update-activation-*.mjs 的 decode():

if (!matchesInstallation(descriptor) && !isPackageActivationComplete(anchor, record)) {
  if (!allowSettlementInspection || !["prepared","publishing","publication-complete","superseded"]
      .includes(record.phase))
    throw new Error("Package publication journal does not match its installation");
  inspectRemount(descriptor);
}

而 matchesInstallation() 的实现是:

const matchesInstallation = (descriptor) =>
     descriptor.parentIdentity       === parentIdentity
  && descriptor.journalParentIdentity === journalParentIdentity
  && descriptor.journalIdentity       === journalIdentity;

三个值都是 设备号:inode 字符串。把 journal 里的记录和磁盘实测一比对,真相就出来了:

项目 journal 记录 实际
parentIdentity(node_modules) 16777220:112476678 16777221:112476678
journalParentIdentity(control 目录) 16777220:124888149 16777221:124888149
journalIdentity(operation.sqlite) 16777220:124888151 16777221:124888151

inode 全部对得上,只有设备号从 16777220 变成了 16777221 —— 卷重挂/重启就会变。哪怕 inspectRemount() 是专门为"设备漂移"写的,它要求所有 inode 一致且设备映射自洽,一旦有一项对不上就抛 Package settlement inode or device mapping changed.。

这就是为什么 openclaw update repair --yes 只回一句错、什么都不做:在 journal 不可结算时它没有可走的路径。

根因 B:Node 版本门

清掉 journal 后重跑,package-install 阶段失败:

npm error command /bin/sh -c node scripts/preinstall-package-manager-warning.mjs
npm error [openclaw] install Node: https://nodejs.org/en/download
npm error [openclaw] upgrade Node, then retry the OpenClaw update.
⚠️ OpenClaw update failed: global-install-failed.

npm view openclaw@2026.10.7 engines 给出实际要求:

{ "node": ">=24.22.1 <25 || >=26.12.1" }

本机是 2026-09 装的 Node 26.10.0,差一点点。

本机 Node 是用户级 tarball 布局(没有 nvm/fnm/volta):

~/.local/node/                 ← 解包目录(bin include lib share)
~/.local/bin/node|npm|npx      ← 绝对路径符号链接指向上面的 bin
~/Library/LaunchAgents/ai.openclaw.gateway.plist → ~/.local/node/bin/node

所以升级 Node 就是替换整个目录。两个坑:

  • 架构要对:这台是 Intel(x86_64),不是 Apple Silicon。uname -m 是 x86_64,得下 node-vX-darwin-x64.tar.gz,别顺手拿了 arm64 包。
  • nodejs.org 在这台很慢(~110 KB/s),57MB 要 9 分钟。curl -m 300 每轮都被腰斩,结果文件只有 33MB、SHA256 必然不匹配。必须 -C - 断点续传 + 长 --max-time。

根因 C:升级成功但网关没起来

package-install 通过后,validating 821s、activating 1906s 都走完,磁盘上已经是 2026.10.7。但 restarting 阶段失败:

⚠️ OpenClaw update failed: state-migrated-no-rollback.
Failed: gateway recovery verification — Exit code: 1;
        Gateway did not settle; startup phase: waiting for managed service
Recorded verification: service stopped; channels not ready; HTTP not ready.

检查发现 LaunchAgent 被 bootout 了且没有重新 bootstrap:

launchctl list | grep openclaw     # 空
lsof -nP -iTCP:18789 -sTCP:LISTEN  # 空
ls ~/Library/LaunchAgents/ai.openclaw.gateway.plist   # 还在(更新流程刚重写过)

plist 在、服务没加载 —— 正是更新流程自己提示的那种状态。

修复

1. 清理孤儿 journal(不可结算时)

先试官方 helper,能结算就别手动动目录:

ANCHOR=~/.local/lib/node_modules/.openclaw.package-activation-<hash>
~/.local/node/bin/node "$ANCHOR.control/recovery.mjs" \
  --anchor "$ANCHOR" --operation <operation-id> status   # 也支持 repair / retire

repair 在 publication-complete 下是空操作(phase 不变、安装 inode 不变);retire 才推进状态。

若设备号已漂移(helper 报 Package settlement inode or device mapping changed.),只能把两件东西移走 —— 移动,不要删,留作证据:

BK=~/.openclaw/backups/update-leftovers-$(date +%Y%m%d)
mkdir -p "$BK"
mv "$ANCHOR" "$ANCHOR.control" "$BK"/

<anchor> 是上一版的回滚副本(约 600MB),与 live 安装(node_modules/openclaw)是不同 inode,移走不影响运行。

2. 升级 Node

V=v26.12.1
TARBALL="node-$V-darwin-x64.tar.gz"     # Intel!Apple Silicon 才是 arm64
cd /tmp
curl -fL -C - --max-time 900 -o "$TARBALL" "https://nodejs.org/dist/$V/$TARBALL"
shasum -a 256 -c <(curl -fsL "https://nodejs.org/dist/$V/SHASUMS256.txt" | grep " $TARBALL\$")

tar -xzf "$TARBALL"
mv ~/.local/node ~/.local/node-26.10.0.bak       # 保留可回滚
mv "node-$V-darwin-x64" ~/.local/node
node -v && npm -v                                 # v26.12.1 / 11.20.0

全局包在 ~/.local/lib/node_modules,与 node 自带的 ~/.local/node/lib/node_modules 不重叠,替换目录不会丢包。

3. 重新启动网关

openclaw gateway install --force

然后验证 readyz / healthz 变 200、launchctl list | grep openclaw 有 PID、18789 有监听。

4. journal 收尾(关键,别漏)

升级完成后 journal 大概率停在 publication-complete,这会让下一次 /update 再挂一次:

~/.local/node/bin/node "$ANCHOR.control/recovery.mjs" \
  --anchor "$ANCHOR" --operation <id> retire
# {"phase":"complete", …}

之后 openclaw update status 应显示 Package recovery: complete,journal 的 phase 变成 anchor-retired 且 intent 为 unlink-helper —— 满足 isPackageActivationComplete(),闸门才会放行。

验收

项 值
OpenClaw 2026.10.7 (157d8c2)
Node / npm v26.12.1 (x64) / 11.20.0
网关 readyz=200 healthz=200,LaunchAgent 已加载
通道 Telegram connected、Feishu connected
出站实测 telegram outbound send ok … messageId=2288
升级记录 Package recovery: complete

升级阶段耗时参考(同一台机器):requested 102s → staging 0.8s → validating 821s → activating 1906s → restarting 132s,整轮约 50 分钟。

两个附带结论

  • sendRichMessage 偶发 Network request … failed 是瞬时抖动。它容易和"升级把 bot 搞坏"混淆。先用原生 API 分离网络与应用:

    curl -s "https://api.telegram.org/bot$TOKEN/getMe"
    curl -s -X POST "https://api.telegram.org/bot$TOKEN/sendMessage" \
      -d chat_id=<chat> -d text=test
    

    两条都通、openclaw message send 重试就好,不用关 channels.telegram.richMessages。

  • 别在网关运行中替换 Node 二进制再升级。这次 previous gateway verification … Ended (unverified) 就是它导致的,而且日志明说 automatic rollback cannot restart it —— 一旦激活失败,自动回滚也救不回来。

命令速查

# 1. 看更新状态与恢复记录
openclaw update status

# 2. 网关日志里的升级事件
openclaw logs --channel gateway --since 30m | grep -E 'update|recovery|package-install|Phase:'

# 3. package-activation journal 的官方 helper
~/.local/node/bin/node <anchor>.control/recovery.mjs \
  --anchor <anchor> --operation <id> status|repair|retire

# 4. 官方修复路径
openclaw update repair --yes

# 5. 服务被 bootout 后恢复
openclaw gateway install --force
openclaw gateway status --deep

# 6. 发布前确认闸门已放行
openclaw update status | grep 'Package recovery'

参考资料

  • 上游 #167655:updater-runtime-retention hard-link 导致源文件 ctime 变化,使同 inode 同字节的安装树指纹校验失败;#162365 在 2026.10.1 改为延迟清理。
  • 本项目此前两次同型事故:update-reports/2026-10-11-package-activation-deadlock.md(stranded aborted 记录)、2026-10-19 遗留 journal。
  • 同目录相关笔记:openclaw-upgrade-swap-scan-timeout.md、openclaw-session-repair-legacy-migration.md。