维护
更新
让 OpenClaw 保持最新。
推荐:openclaw update
最快的更新方式。它会检测你的安装类型(npm 或 git)、获取最新版本、运行 openclaw doctor,并重启 Gateway 网关。
openclaw update
要切换渠道或指定特定版本:
openclaw update --channel beta
openclaw update --channel dev
openclaw update --tag main
openclaw update --dry-run # preview without applying
openclaw update 不接受 --verbose。如需更新诊断,请使用 --dry-run 预览计划执行的操作,使用 --json 获取结构化结果,或使用 openclaw update status --json 检查渠道和可用性状态。安装器有自己的 --verbose 标志,但该标志不是 openclaw update 的一部分。
--channel beta 优先使用 beta,但当 beta 标签缺失或早于最新稳定版时,运行时会回退到 stable/latest。如果你想对一次性包更新使用原始 npm beta dist-tag,请使用 --tag beta。
渠道语义见 开发渠道。
在 npm 和 git 安装之间切换
当你想更改安装类型时,请使用渠道。更新器会保留你在 ~/.openclaw 中的状态、配置、凭证和工作区;它只会更改 CLI 和 Gateway 网关使用的 OpenClaw 代码安装位置。
# npm package install -> editable git checkout
openclaw update --channel dev
# git checkout -> npm package install
openclaw update --channel stable
先使用 --dry-run 运行,以预览确切的安装模式切换:
openclaw update --channel dev --dry-run
openclaw update --channel stable --dry-run
dev 渠道会确保存在 git 检出、构建它,并从该检出安装全局 CLI。stable 和 beta 渠道使用包安装。如果 Gateway 网关已经安装,openclaw update 会刷新服务元数据并重启它,除非你传入 --no-restart。
替代方式:重新运行安装器
curl -fsSL https://openclaw.ai/install.sh | bash
添加 --no-onboard 可跳过新手引导。要通过安装器强制指定安装类型,请传入 --install-method git --no-onboard 或 --install-method npm --no-onboard。
如果 openclaw update 在 npm 包安装阶段后失败,请重新运行安装器。安装器不会调用旧的更新器;它会直接运行全局包安装,并可恢复部分更新的 npm 安装。
curl -fsSL https://openclaw.ai/install.sh | bash -s -- --install-method npm
要将恢复固定到特定版本或 dist-tag,请添加 --version:
curl -fsSL https://openclaw.ai/install.sh | bash -s -- --install-method npm --version <version-or-dist-tag>
替代方式:手动 npm、pnpm 或 bun
npm i -g openclaw@latest
对于受监督的安装,建议使用 openclaw update,因为它可以把包切换与正在运行的 Gateway 网关服务协调起来。如果你在托管的 Gateway 网关运行时手动更新,请在包管理器完成后立即重启 Gateway 网关,避免旧进程继续从已替换的包文件提供服务。
当 openclaw update 管理全局 npm 安装时,它会先把目标安装到临时 npm 前缀中,验证打包的 dist 清单,然后把干净的包树切换到真正的全局前缀。这样可以避免 npm 将新包覆盖到旧包遗留文件之上。如果安装命令失败,OpenClaw 会使用 --omit=optional 重试一次。这个重试有助于那些原生可选依赖无法编译的主机,同时如果回退也失败,仍会保留原始失败信息。
pnpm add -g openclaw@latest
bun add -g openclaw@latest
高级 npm 安装主题
只读包树
OpenClaw 在运行时会将打包的全局安装视为只读,即使当前用户对全局包目录有写入权限也是如此。插件包安装位于用户配置目录下由 OpenClaw 拥有的 npm/git 根目录中,Gateway 网关启动不会修改 OpenClaw 包树。
一些 Linux npm 设置会把全局包安装到 root 拥有的目录下,例如 /usr/lib/node_modules/openclaw。OpenClaw 支持这种布局,因为插件安装/更新命令会写入到该全局包目录之外。
加固的 systemd 单元
授予 OpenClaw 对其配置/状态根目录的写入权限,以便显式插件安装、插件更新和 Doctor 清理能够持久化其更改:
ReadWritePaths=/var/lib/openclaw /home/openclaw/.openclaw /tmp
磁盘空间预检
在包更新和显式插件安装之前,OpenClaw 会尽力对目标卷进行磁盘空间检查。空间不足会生成带有已检查路径的警告,但不会阻止更新,因为文件系统配额、快照和网络卷可能会在检查后发生变化。实际的包管理器安装和安装后验证仍是权威依据。
自动更新器
自动更新器默认关闭。在 ~/.openclaw/openclaw.json 中启用它:
{
update: {
channel: "stable",
auto: {
enabled: true,
stableDelayHours: 6,
stableJitterHours: 12,
betaCheckIntervalHours: 1,
},
},
}
| 渠道 | 行为 |
|---|---|
stable |
等待 stableDelayHours,然后在 stableJitterHours 范围内使用确定性抖动应用更新(分散发布)。 |
beta |
每隔 betaCheckIntervalHours 检查一次(默认:每小时),并立即应用。 |
dev |
不自动应用。请手动使用 openclaw update。 |
Gateway 网关还会在启动时记录更新提示(使用 update.checkOnStart: false 禁用)。
对于降级或事故恢复,请在 Gateway 网关环境中设置 OPENCLAW_NO_AUTO_UPDATE=1,以便即使配置了 update.auto.enabled 也阻止自动应用。除非也禁用了 update.checkOnStart,否则启动更新提示仍可运行。
通过实时 Gateway 网关控制平面处理程序请求的包管理器更新,会在包切换后强制进行非延迟、无冷却时间的更新重启。这样可避免旧的内存中进程停留过久,进而从已经被替换的包树中懒加载分块。对于受监督的安装,shell openclaw update 仍是首选路径,因为它可以在更新前后停止并重启服务。
更新后
运行 Doctor
openclaw doctor
迁移配置、审计私信策略,并检查 Gateway 网关健康状况。详情:Doctor
重启 Gateway 网关
openclaw gateway restart
验证
openclaw health
回滚
固定版本(npm)
npm i -g openclaw@<version>
openclaw doctor
openclaw gateway restart
固定提交(源码)
git fetch origin
git checkout "$(git rev-list -n 1 --before=\"2026-01-01\" origin/main)"
pnpm install && pnpm build
openclaw gateway restart
要返回到最新版本:git checkout main && git pull。
如果你卡住了
- 再次运行
openclaw doctor,并仔细阅读输出。 - 对于源码检出上的
openclaw update --channel dev,更新器会在需要时自动引导pnpm。如果你看到 pnpm/corepack 引导错误,请手动安装pnpm(或重新启用corepack),然后重新运行更新。 - 查看:故障排除
- 在 Discord 中提问:https://discord.gg/clawd