Skip to content

更新

OpenClaw 正在快速迭代(1.0 版本之前)。像对待基础设施一样对待更新:更新 → 运行检查 → 重启(或使用 openclaw update,它会自动重启)→ 验证。

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

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

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

注意:

  • 如果不想再次运行引导向导,请添加 --no-onboard
  • 对于源码安装,使用:
    bash
    curl -fsSL https://openclaw.ai/install.sh | bash -s -- --install-method git --no-onboard
    安装程序仅在仓库干净时才会 git pull --rebase
  • 对于全局安装,脚本在底层使用 npm install -g openclaw@latest
  • 历史遗留说明:clawdbot 仍可作为兼容性适配层使用。

更新前

  • 了解你的安装方式:全局安装(npm/pnpm)vs 源码安装(git clone)。
  • 了解你的网关运行方式:前台终端 vs 守护进程服务(launchd/systemd)。
  • 备份你的定制内容:
    • 配置:~/.openclaw/openclaw.json
    • 凭据:~/.openclaw/credentials/
    • 工作空间:~/.openclaw/workspace

更新(全局安装)

全局安装(选择其一):

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

我们不推荐使用 Bun 作为网关运行时(存在 WhatsApp/Telegram bug)。

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

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

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

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

注意:在 npm 安装时,网关启动时会记录更新提示(检查当前渠道标签)。可通过 update.checkOnStart: false 禁用。

然后:

bash
openclaw doctor
openclaw gateway restart
openclaw health

注意:

  • 如果你的网关作为服务运行,推荐使用 openclaw gateway restart 而不是杀掉 PID。
  • 如果你固定到特定版本,请参见下面的"回滚/固定版本"。

更新(openclaw update)

对于源码安装(git checkout),推荐:

bash
openclaw update

它执行一个较为安全的更新流程:

  • 要求工作树干净。
  • 切换到选定的渠道(标签或分支)。
  • 拉取并基于配置的上游进行变基(dev 渠道)。
  • 安装依赖、构建、构建控制界面,并运行 openclaw doctor
  • 默认重启网关(使用 --no-restart 跳过)。

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

更新(控制界面/RPC)

控制界面有 Update & Restart(RPC:update.run)。它会:

  1. 运行与 openclaw update 相同的源码更新流程(仅 git checkout)。
  2. 写入一个重启标记,包含结构化报告(stdout/stderr 尾部)。
  3. 重启网关并向最后活跃的会话发送报告。

如果变基失败,网关会中止并在不应用更新的情况下重启。

更新(从源码)

从仓库检出目录:

推荐:

bash
openclaw update

手动(基本等效):

bash
git pull
pnpm install
pnpm build
pnpm ui:build # auto-installs UI deps on first run
openclaw doctor
openclaw health

注意:

  • 当你运行打包的 openclaw 二进制文件(openclaw.mjs)或使用 Node 运行 dist/ 时,pnpm build 很重要。
  • 如果从仓库检出运行而未全局安装,CLI 命令请使用 pnpm openclaw ...
  • 如果直接从 TypeScript 运行(pnpm openclaw ...),通常不需要重新构建,但配置迁移仍然适用 → 运行 doctor。
  • 在全局安装和 git 安装之间切换很容易:安装另一种方式,然后运行 openclaw doctor,这样网关服务入口点会被重写为当前安装。

始终运行:openclaw doctor

Doctor 是"安全更新"命令。它故意设计得很简单:修复 + 迁移 + 警告。

注意:如果你是源码安装(git checkout),openclaw doctor 会提示先运行 openclaw update

它通常会做以下事情:

  • 迁移已弃用的配置键/旧版配置文件位置。
  • 审计 DM 策略并对有风险的"开放"设置发出警告。
  • 检查网关健康状态,可以提供重启建议。
  • 检测并迁移旧版网关服务(launchd/systemd;旧版 schtasks)到当前 OpenClaw 服务。
  • 在 Linux 上,确保 systemd 用户持久化(使网关在登出后继续运行)。

详情:Doctor

启动/停止/重启网关

CLI(适用于所有操作系统):

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

如果使用守护进程:

  • macOS launchd(应用捆绑的 LaunchAgent):launchctl kickstart -k gui/$UID/bot.molt.gateway(使用 bot.molt.<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

运维手册和确切的服务标签:网关运维手册

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

固定版本(全局安装)

安装已知良好的版本(将 <version> 替换为最后一个可用版本):

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

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

然后重启并重新运行 doctor:

bash
openclaw doctor
openclaw gateway restart

按日期固定版本(源码)

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

bash
git fetch origin
git checkout "$(git rev-list -n 1 --before=\"2026-01-01\" origin/main)"

然后重新安装依赖并重启:

bash
pnpm install
pnpm build
openclaw gateway restart

如果之后想回到最新版本:

bash
git checkout main
git pull

如果遇到问题