OpenClaw从入门到应用——安装:更新OpenClaw

通过OpenClaw实现副业收入《OpenClaw赚钱实录:从"养龙虾"到可持续变现的实践指南》

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

首选 的更新方式是重新运行官网提供的安装脚本。该脚本会自动检测现有安装,执行原地升级,并在需要时运行 openclaw doctor

bash 复制代码
curl -fsSL https://openclaw.ai/install.sh | bash

注意事项:

  • 如果你不希望再次触发引导向导(onboarding wizard),请添加 --no-onboard 参数。

  • 对于源码安装 (source installs),请使用:

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

    安装程序仅当代码仓库干净(无未提交更改)时 才会执行 git pull --rebase

  • 对于全局安装 (global installs),脚本内部实际调用的是 npm install -g openclaw@latest

  • 兼容性说明:旧名称 clawdbot 仍作为兼容层(compatibility shim)保留可用。

更新前须知

  • 确认你的安装方式:全局安装 (通过 npm/pnpm)还是 源码安装(通过 git clone)。
  • 确认你的 Gateway 是如何运行的:是在 前台终端 中手动启动,还是作为 受监管的服务(如 macOS 的 launchd 或 Linux 的 systemd)运行。
  • 备份你的个性化配置:
    • 配置文件:~/.openclaw/openclaw.json
    • 凭据信息:~/.openclaw/credentials/
    • 工作空间:~/.openclaw/workspace

更新(全局安装)

全局安装请选择以下任一命令:

bash 复制代码
npm i -g openclaw@latest
bash 复制代码
pnpm add -g openclaw@latest

我们不推荐在 Gateway 运行时使用 Bun(因其存在 WhatsApp/Telegram 相关的已知问题)。

若要切换更新通道(适用于 git + npm 安装):

bash 复制代码
openclaw update --channel beta
openclaw update --channel dev
openclaw update --channel stable

如需一次性安装特定标签或版本,请使用 --tag <标签/版本>

有关各通道的具体语义和发布说明,请参阅 开发通道

注意:对于 npm 安装,Gateway 启动时会自动检查当前通道是否有新版本并提示更新。可通过设置 update.checkOnStart: false 来禁用此行为。

核心自动更新器(可选)

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

json 复制代码
{
  "update": {
    "channel": "stable",
    "auto": {
      "enabled": true,
      "stableDelayHours": 6,
      "stableJitterHours": 12,
      "betaCheckIntervalHours": 1
    }
  }
}

行为说明:

  • stable(稳定通道):检测到新版本后,OpenClaw 会等待 stableDelayHours 小时,然后在此基础上叠加一个确定性的、每个安装实例不同的随机延迟(范围为 stableJitterHours 小时),以实现滚动更新。
  • beta(测试通道):按 betaCheckIntervalHours 的间隔(默认每小时)检查更新,并在有新版本时立即应用。
  • dev(开发通道):不会自动应用更新;请使用手动命令 openclaw update

在启用自动更新前,建议先运行 openclaw update --dry-run 预览即将执行的操作。

启用后,请执行:

bash 复制代码
openclaw doctor
openclaw gateway restart
openclaw health

注意事项:

  • 如果你的 Gateway 以服务形式运行,建议优先使用 openclaw gateway restart,而不是直接 kill 进程 ID。
  • 如果你希望锁定某个特定版本,请参见下方"回滚 / 固定版本"部分。

更新(openclaw update 命令)

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

bash 复制代码
openclaw update

该命令会执行一套相对安全的更新流程:

  • 要求工作区干净(无未提交更改);
  • 切换到所选的更新通道(标签或分支);
  • 从配置的上游仓库拉取最新变更并执行 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. 写入一个重启标记文件(sentinel),其中包含结构化的更新报告(含 stdout/stderr 的末尾日志);
  3. 重启 Gateway,并将报告推送给上一个活跃会话。

如果 rebase 失败,Gateway 会中止更新并直接重启,不会应用任何更改。

更新(从源码手动操作)

在仓库目录中操作:

推荐方式:

bash 复制代码
openclaw update

手动方式(效果大致等同):

bash 复制代码
git pull
pnpm install
pnpm build
pnpm ui:build # 首次运行时会自动安装 UI 依赖
openclaw doctor
openclaw health

注意事项:

  • 当你运行打包后的 openclaw 二进制文件(即 openclaw.mjs)或通过 Node 直接运行 dist/ 目录下的产物时,pnpm build 步骤至关重要。
  • 如果你是从源码仓库直接运行(未进行全局安装),请使用 pnpm openclaw ... 来执行 CLI 命令。
  • 如果你直接从 TypeScript 源码运行(即 pnpm openclaw ...),通常无需重新构建,但配置迁移仍然生效 → 务必运行 openclaw doctor
  • 在全局安装和源码安装之间切换非常简单:只需安装另一种形式,然后运行 openclaw doctor,它会自动将 Gateway 服务的入口点重写为当前安装的版本。

务必运行:openclaw doctor

doctor 是"安全更新"的核心命令。它的设计原则就是"平淡无奇":修复 + 迁移 + 警告。

注意:如果你使用的是 源码安装 (git checkout),openclaw doctor 会主动建议你先运行 openclaw update

它通常会执行以下操作:

  • 迁移已弃用的配置项或旧版配置文件路径;
  • 审计私信(DM)策略,并对存在风险的"开放"设置发出警告;
  • 检查 Gateway 健康状态,并可提供重启建议;
  • 检测并迁移旧版的 Gateway 服务(如 launchd/systemd 或遗留的 schtasks)至当前 OpenClaw 服务;
  • 在 Linux 上,确保启用了 systemd 用户 lingering 功能(使 Gateway 在用户登出后仍能继续运行)。

更多细节请参阅:Doctor

启动 / 停止 / 重启 Gateway

CLI 命令(跨平台通用):

bash 复制代码
openclaw gateway status
openclaw gateway stop
openclaw gateway restart
openclaw gateway --port 18789
openclaw logs --follow

如果你的 Gateway 由系统服务监管:

  • macOS launchd (应用捆绑的 LaunchAgent):

    bash 复制代码
    launchctl kickstart -k gui/$UID/ai.openclaw.gateway

    (使用 ai.openclaw. 前缀;旧版 com.openclaw.* 依然兼容)

  • Linux systemd 用户服务

    bash 复制代码
    systemctl --user restart openclaw-gateway[-].service
  • Windows (WSL2)

    bash 复制代码
    systemctl --user restart openclaw-gateway[-].service

注意:launchctl/systemctl 命令仅在服务已安装的情况下有效;否则请先运行 openclaw gateway install

具体操作手册及服务标签详情请参阅:Gateway 操作手册

回滚 / 固定版本(当更新出错时)

固定版本(全局安装)

安装一个已知正常的版本(将 <版本号> 替换为你上次正常工作的版本号):

bash 复制代码
npm i -g openclaw@<版本号>
bash 复制代码
pnpm add -g openclaw@<版本号>

小技巧:要查看当前发布的最新版本,可运行 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

如果遇到问题无法解决

相关推荐
beyond阿亮4 小时前
OpenClaw在Windows上接入飞书完整指南
人工智能·windows·ai·openclaw
m0_651593914 小时前
WSL2固定Nacos IP访问Win10服务
wsl2·openclaw
量子炒饭大师5 小时前
【OpenClaw修炼宝典】—— 【macOS安装篇】想玩《爪子船长》复刻版却卡在安装?OpenClaw 从零环境搭建与编译全攻略 (小白避坑指南)
macos·openclaw·小龙虾·龙虾
code小生6 小时前
OpenClaw 是什么?它和 AI工具 以及 Agent 之间是什么关系?
人工智能·openclaw·openclaw与ai·openclaw与agent·openclaw与智能体
G皮T6 小时前
【人工智能】探索 OpenClaw 的实际应用:让 AI Agent 真正改善你的生活
人工智能·ai·agent·skill·openclaw
MadPrinter6 小时前
GitHub Trending 每日精选 - 2026-03-28
ai·自动化·github·openclaw
Neolnfra6 小时前
用 QClaw 自动化运营小红书:对话式操控全攻略
小红书·openclaw·qclaw
AC赳赳老秦6 小时前
OpenClaw SEO写手Agent实操:生成结构化文章,适配CSDN搜索规则
大数据·人工智能·python·搜索引擎·去中心化·deepseek·openclaw