全局更新前先做 ownership 预检:避免 root 文件导致 update 半损坏
问题/场景:`openclaw update` 在目录含 root-owned 文件时可能 EACCES,留下不完整安装。前置条件:npm global 安装且历史上用过 sudo 安装技能/文件。实施步骤:更新前扫描目录 owner → 发现异主文件先 chown 修复 → 再执行更新并重启。关键命令:openclaw gateway status、openclaw gateway restart。验证:更新后 dist/package.json/openclaw.mjs 完整存在。风险:跨平台 owner 检测差异(Windows 等)需验证。来源:PR #20585。
GITHUBDiscovered 2026-02-19Author mwfj
Prerequisites
- OpenClaw installed globally via npm/homebrew path where file ownership mismatches are possible.
- Operator has permission to inspect and repair ownership in install directory.
Steps
- Before running any update, inspect install dir ownership and identify files not owned by current user.
- If foreign-owned files are found, fix ownership first (upstream remediation suggests `chown -R $(whoami) <path>`).
- Run OpenClaw update flow only after ownership check passes.
- Restart gateway and run minimal command checks to ensure package is not partially missing.
Commands
openclaw gateway statusopenclaw gateway restartopenclaw helpVerify
After update, CLI commands run normally and installation folder still contains required runtime files.
Caveats
- Avoid repeated sudo-based plugin installs into the same global tree, otherwise ownership drift can recur.
- Windows and uid-less environments may require alternative checks(需验证).
Source attribution
This tip is aggregated from community/public sources and preserved with attribution.
Open original source ↗