更新

更新

OpenClaw 发展迅速(尚未发布 "1.0")。将更新视为基础设施部署:更新 → 运行检查 → 重启(或使用 openclaw update,它会自动重启)→ 验证。

推荐:重新运行网站安装程序(原地升级)

首选的更新方式是重新运行网站上的安装程序。它会检测现有安装,原地升级,并在需要时运行 openclaw doctor

curl -fsSL https://openclaw.ai/install.sh | bash

注意事项:

  • 如果不想再次运行引导向导,添加 --no-onboard

  • 对于源码安装,使用:

    curl -fsSL https://openclaw.ai/install.sh | bash -s -- --install-method git --no-onboard
    

    仅当仓库处于干净状态时,安装程序才会执行 git pull --rebase

  • 对于全局安装,脚本在底层使用 npm install -g openclaw@latest

  • 兼容性说明:clawdbot 作为兼容性 shim 仍然可用。

更新前

  • 了解你的安装方式:全局(npm/pnpm)vs 源码(git clone)。
  • 了解 Gateway 的运行方式:前台终端 vs 托管服务(launchd/systemd)。
  • 备份你的定制配置:
    • 配置:~/.openclaw/openclaw.json
    • 凭证:~/.openclaw/credentials/
    • 工作区:~/.openclaw/workspace

更新(全局安装)

全局安装(任选其一):

npm i -g openclaw@latest
pnpm add -g openclaw@latest

我们不推荐将 Bun 用于 Gateway 运行时(存在 WhatsApp/Telegram bug)。

切换更新通道(git + npm 安装):

openclaw update --channel beta
openclaw update --channel dev
openclaw update --channel stable

使用 --tag <dist-tag|version> 进行一次性安装标签/版本指定。

查看 开发通道 了解通道语义和发布说明。

注意:在 npm 安装上,Gateway 启动时会在日志中显示更新提示(检查当前通道标签)。可通过 update.checkOnStart: false 禁用。

核心自动更新器(可选)

自动更新器默认关闭,是核心 Gateway 功能(不是插件)。

{
  "update": {
    "channel": "stable",
    "auto": {
      "enabled": true,
      "stableDelayHours": 6,
      "stableJitterHours": 12,
      "betaCheckIntervalHours": 1
    }
  }
}

行为说明:

  • stable:当检测到新版本时,OpenClaw 等待 stableDelayHours,然后应用基于每个安装的确定性抖动 stableJitterHours(分散 rollout)。
  • beta:按 betaCheckIntervalHours 间隔检查(默认:每小时),有可用更新时应用。
  • dev:不自动应用;使用手动 openclaw update

使用 openclaw update --dry-run 在启用自动化前预览更新操作。

然后:

openclaw doctor
openclaw gateway restart
openclaw health

注意事项:

  • 如果 Gateway 以服务运行,优先使用 openclaw gateway restart 而不是杀死进程。
  • 如果固定到特定版本,见下方"回滚/固定"部分。

更新(openclaw update

对于源码安装(git checkout),优先使用:

openclaw update

它运行一个相对安全的更新流程:

  • 要求工作树干净。
  • 切换到选定的通道(tag 或 branch)。
  • 获取并 rebase 到配置的上游(dev 通道)。
  • 安装依赖、构建、构建 Control UI,并运行 openclaw doctor
  • 默认重启 gateway(使用 --no-restart 跳过)。

如果通过 npm/pnpm 安装(无 git 元数据),openclaw update 会尝试通过包管理器更新。如果无法检测安装方式,改用"更新(全局安装)"。

更新(Control UI / RPC)

Control UI 有 Update & Restart(RPC:update.run)。它:

  1. 运行与 openclaw update 相同的源码更新流程(仅限 git checkout)。
  2. 写入带有结构化报告的重启哨兵(stdout/stderr tail)。
  3. 重启 gateway 并向最后活跃会话发送报告。

如果 rebase 失败,gateway 中止并重启,不应用更新。

更新(源码)

从仓库 checkout:

推荐:

openclaw update

手动(等效):

git pull
pnpm install
pnpm build
pnpm ui:build # 首次运行时自动安装 UI 依赖
openclaw doctor
openclaw health

注意事项:

  • 当运行打包的 openclaw 二进制文件(openclaw.mjs)或使用 Node 运行 dist/ 时,pnpm build 很重要。
  • 如果从 repo checkout 运行而无全局安装,使用 pnpm openclaw ... 运行 CLI 命令。
  • 如果直接从 TypeScript 运行(pnpm openclaw ...),通常无需重建,但配置迁移仍然适用 → 运行 doctor。
  • 在全局和 git 安装之间切换很容易:安装另一种风味,然后运行 openclaw doctor,gateway 服务入口点会重写为当前安装。

始终运行:openclaw doctor

Doctor 是"安全更新"命令。它故意枯燥:修复 + 迁移 + 警告。

注意:如果使用源码安装(git checkout),openclaw doctor 会先提供运行 openclaw update

典型操作:

  • 迁移已弃用的配置键/旧配置文件位置。
  • 审计 DM 策略并警告有风险的"开放"设置。
  • 检查 Gateway 健康并可提议重启。
  • 检测并迁移旧的 gateway 服务(launchd/systemd;旧版 schtasks)到当前 OpenClaw 服务。
  • 在 Linux 上,确保 systemd 用户 linger(使 Gateway 在登出后存活)。

详情:Doctor

启动/停止/重启 Gateway

CLI(适用于任何 OS):

openclaw gateway status
openclaw gateway stop
openclaw gateway restart
openclaw gateway --port 18789
openclaw logs --follow

如果托管:

  • macOS launchd(app-bundled LaunchAgent):launchctl kickstart -k gui/$UID/ai.openclaw.gateway(使用 ai.openclaw.<profile>;旧版 com.openclaw.* 仍然有效)
  • Linux systemd 用户服务:systemctl --user restart openclaw-gateway[-<profile>].service
  • Windows(WSL2):systemctl --user restart openclaw-gateway[-<profile>].service
    • 仅当服务已安装时 launchctl/systemctl 才有效;否则运行 openclaw gateway install

运行手册 + 确切服务标签:Gateway 运行手册

回滚/固定(当出现问题时)

固定(全局安装)

安装已知良好的版本(将 <version> 替换为最后正常工作的版本):

npm i -g openclaw@<version>
pnpm add -g openclaw@<version>

提示:查看当前发布版本,运行 npm view openclaw version

然后重启并重新运行 doctor:

openclaw doctor
openclaw gateway restart

按日期固定(源码)

选择某个日期的提交(示例:"2026-01-01 的 main 状态"):

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

如果卡住