更新
保持 OpenClaw 為最新狀態。
建議:openclaw update
Section titled “建議:openclaw update”最快的更新方式。它會偵測您的安裝類型(npm 或 git),取得最新版本,執行 openclaw doctor,然後重新啟動閘道。
openclaw update若要切換頻道或指定特定版本:
openclaw update --channel betaopenclaw update --channel devopenclaw update --tag mainopenclaw update --dry-run # preview without applyingopenclaw 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 安裝之間切換
Section titled “在 npm 和 git 安裝之間切換”當您想要變更安裝類型時,請使用頻道。更新程式會將您的狀態、設定、認證和
工作區保留在 ~/.openclaw 中;它只會變更 CLI 和閘道所使用的 OpenClaw 程式碼安裝。
# npm package install -> editable git checkoutopenclaw update --channel dev
# git checkout -> npm package installopenclaw update --channel stable先執行 --dry-run 以預覽確切的安裝模式切換:
openclaw update --channel dev --dry-runopenclaw update --channel stable --dry-rundev 頻道會確保 git checkout,進行建置,並從該 checkout 安裝全域 CLI。
stable 和 beta 頻道則使用套件安裝。如果閘道
已安裝,openclaw update 會重新整理服務中繼資料並重新啟動它,除非您傳遞
--no-restart。
對於具有受管理 Gateway 服務的套件安裝,openclaw update 會以該服務使用的套件根目錄為目標。如果 Shell openclaw 指令來自不同的安裝,更新程式會列印出這兩個根目錄以及受管理服務的 Node 路徑。套件更新會使用擁有該服務根目錄的套件管理器,並在更換套件之前檢查受管理服務的 Node 版本是否符合目標發行版本的引擎需求。
替代方案:重新執行安裝程式
Section titled “替代方案:重新執行安裝程式”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若要將恢復作業鎖定在特定版本或發行標籤,請加入 --version:
curl -fsSL https://openclaw.ai/install.sh | bash -s -- --install-method npm --version <version-or-dist-tag>替代方案:手動使用 npm、pnpm 或 bun
Section titled “替代方案:手動使用 npm、pnpm 或 bun”npm i -g openclaw@latest對於受監管的安裝,建議優先使用 openclaw update,因為它可以協調套件交換與正在執行的 Gateway 服務。如果您在受監管的安裝上手動更新,請在套件管理器啟動前停止受管理的 Gateway。套件管理器會就地替換檔案,否則正在執行的 Gateway 可能會嘗試在套件樹狀結構暫時處於半交換狀態時載入核心或外掛檔案。在套件管理器完成後重新啟動 Gateway,以便服務能夠使用新的安裝。
對於 root 擁有的 Linux 系統全域安裝,如果 openclaw update 失敗並顯示
EACCES,且您使用系統 npm 進行恢復,請在手動更換套件期間保持 Gateway 停止狀態。使用您通常用於該 Gateway 的相同 openclaw``/usr/bin/npm 設定檔旗標或環境變數。將 %%PH:INLINE_CODE:59:1acacea88%% 替換為您主機上擁有 root 擁有全域前綴的系統 npm:
openclaw gateway stopsudo /usr/bin/npm i -g openclaw@latestopenclaw gateway install --forceopenclaw gateway restart然後驗證服務:
openclaw --versioncurl -fsS http://127.0.0.1:18789/readyzopenclaw plugins list --jsonopenclaw gateway status --deep --jsonopenclaw doctor --lint --json當 openclaw update 管理全域性 npm 安裝時,它會先將目標安裝到
臨時的 npm 前綴,驗證打包的 dist 清單,然後將
乾淨的套件樹交換到真正的全域性前綴中。這避免了 npm 將
新套件覆蓋在舊套件的過時檔案上。如果安裝命令失敗,
OpenClaw 會使用 --omit=optional 重試一次。該重試有助於解決原生
選用依賴項無法編譯的主機問題,同時如果備用方案也失敗,則保持原始失敗可見。
由 OpenClaw 管理的 npm update 和 plugin-update 命令也會清除子 npm 程序的 npm
min-release-age 檢疫。npm 可能會將該策略報告為衍生的 before 截止;這兩者對於一般的供應鏈
檢疫策略都很有用,但明確的 OpenClaw 更新意味著「現在安裝選定的
OpenClaw 版本」。
pnpm add -g openclaw@latestbun add -g openclaw@latest進階 npm 安裝主題
Section titled “進階 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 會盡力檢查目標磁碟區的磁碟空間。空間不足會產生包含已檢查路徑的警告,但不會阻擋更新,因為檔案系統配額、快照和網路磁碟區在檢查後可能會變動。實際的套件管理程式安裝和安裝後驗證仍具有最終決定權。
自動更新程式
Section titled “自動更新程式”自動更新程式預設為關閉。在 ~/.openclaw/openclaw.json 中啟用它:
{ update: { channel: "stable", auto: { enabled: true, stableDelayHours: 6, stableJitterHours: 12, betaCheckIntervalHours: 1, }, },}| 頻道 | 行為 |
|---|---|
stable | 等待 stableDelayHours,然後在 stableJitterHours 內套用確定性抖動(分階段推出)。 |
beta | 每隔 betaCheckIntervalHours 檢查一次(預設:每小時),並立即套用。 |
dev | 不自動套用。請手動使用 openclaw update。 |
閘道也會在啟動時記錄更新提示(使用 update.checkOnStart: false 停用)。
若要降級或進行事故復原,請在閘道環境中設定 OPENCLAW_NO_AUTO_UPDATE=1 以阻擋自動套用,即使已設定 update.auto.enabled。除非同時停用 update.checkOnStart,否則啟動更新提示仍可執行。
透過即時閘道控制平面處理程序要求的套件管理程式更新
不會置換執行中閘道程序內的套件樹。在受管理
的服務安裝上,閘道會啟動分離的交接,退出,並讓
正常的 openclaw update --yes --json CLI 路徑停止服務、置換
套件、重新整理服務中繼資料、重新啟動、驗證閘道版本和
連線能力,並在
可能時復原已安裝但未載入的 macOS LaunchAgent。如果閘道無法安全進行該交接,update.run 將回報
安全的 shell 指令,而不是在程序內執行套件管理程式。
鎖定版本 (npm)
Section titled “鎖定版本 (npm)”npm i -g openclaw@<version>openclaw doctoropenclaw gateway restart鎖定提交 (source)
Section titled “鎖定提交 (source)”git fetch origingit checkout "$(git rev-list -n 1 --before=\"2026-01-01\" origin/main)"pnpm install && pnpm buildopenclaw gateway restart若要返回最新版本:git checkout main && git pull。
如果您遇到困難
Section titled “如果您遇到困難”- 再次執行
openclaw doctor並仔細閱讀輸出內容。 - 對於原始碼檢出上的
openclaw update --channel dev,更新程式會在需要時自動引導pnpm。如果您看到 pnpm/corepack 引導錯誤,請手動安裝pnpm(或重新啟用corepack) 並重新執行更新。 - 檢查:疑難排解
- 在 Discord 上詢問:https://discord.gg/clawd