OpenClaw 完全卸载指南
🦞 官方卸载命令 + 手动清理,确保 100% 无残留
适用版本:openclaw@2026.3.8+
最后更新:2026-03-13
🚀 快速卸载(一行命令)
官方完全卸载命令
1
| openclaw uninstall --all --yes --non-interactive && npm uninstall -g openclaw
|
执行效果:
- ✅ 删除 Gateway 服务(LaunchAgent)
- ✅ 删除所有配置和数据(
~/.openclaw/) - ✅ 删除 npm 全局包
- ✅ 保留 CLI 命令(卸载后不可用)
📋 命令验证
你提到的命令是否存在?
| 命令 | 是否存在 | 说明 |
|---|
openclaw gateway stop | ✅ 存在 | 正确,停止 Gateway 服务的标准命令 |
openclaw dashboard stop | ❌ 不存在 | dashboard 只是打开网页,无需停止 |
openclaw daemon stop | ✅ 存在 | daemon 是 gateway 的别名,两者等价 |
命令关系说明
1
2
3
4
5
6
| # 以下两个命令等价,任选其一
openclaw gateway stop
openclaw daemon stop
# dashboard 只是打开浏览器,没有 stop 子命令
openclaw dashboard # 仅打开网页
|
📖 详细卸载步骤
方案 A:官方一键卸载(推荐)
1
2
3
4
5
6
7
8
9
10
11
| # 1. 停止服务(可选,uninstall 会自动处理)
openclaw gateway stop
# 2. 执行官方卸载
openclaw uninstall --all --yes --non-interactive
# 3. 卸载 npm 包
npm uninstall -g openclaw
# 4. 验证
which openclaw # 应无输出
|
方案 B:分步手动卸载(精细控制)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| # ========== 第 1 步:停止服务 ==========
openclaw gateway stop
# ========== 第 2 步:卸载服务 ==========
openclaw gateway uninstall
# 或等价命令
openclaw daemon uninstall
# ========== 第 3 步:删除配置和数据 ==========
rm -rf ~/.openclaw
# ========== 第 4 步:卸载 npm 包 ==========
npm uninstall -g openclaw
# ========== 第 5 步:清理残留 ==========
rm -rf /tmp/openclaw
rm -rf ~/Library/Caches/openclaw
rm -rf ~/Library/Logs/openclaw
hash -r # 刷新 shell 缓存
# ========== 第 6 步:验证 ==========
which openclaw # 应无输出
ps aux | grep openclaw # 应无进程
launchctl list | grep openclaw # 应无服务
|
方案 C:预览模式(先看看会删什么)
1
2
| # 预览删除内容(不实际执行)
openclaw uninstall --all --dry-run
|
🔧 命令参数详解
openclaw uninstall 参数
| 参数 | 说明 | 默认值 |
|---|
--all | 删除服务 + 状态 + 工作空间 + 应用 | false |
--service | 仅删除 Gateway 服务 | false |
--state | 删除状态和配置(openclaw.json 等) | false |
--workspace | 删除工作空间目录 | false |
--app | 删除 macOS App | false |
--dry-run | 预览模式(不实际删除) | false |
--yes | 跳过确认提示 | false |
--non-interactive | 禁用交互(脚本友好) | false |
常用组合
1
2
3
4
5
6
7
8
9
10
11
| # 仅卸载服务(保留数据)
openclaw uninstall --service --yes
# 卸载服务 + 配置(保留工作空间)
openclaw uninstall --service --state --yes
# 完全卸载(不含 macOS App)
openclaw uninstall --service --state --workspace --yes --non-interactive
# 完全卸载(包含 macOS App)
openclaw uninstall --all --yes --non-interactive
|
📡 Gateway 服务管理命令
完整命令列表
| 命令 | 说明 | 卸载相关度 |
|---|
openclaw gateway start | 启动服务 | ❌ |
openclaw gateway stop | 停止服务 | ⭐⭐⭐ 必需 |
openclaw gateway restart | 重启服务 | ❌ |
openclaw gateway status | 查看状态 | ⭐ 验证用 |
openclaw gateway install | 安装服务 | ❌ |
openclaw gateway uninstall | 卸载服务 | ⭐⭐⭐ 必需 |
openclaw gateway run | 前台运行(调试) | ❌ |
等价命令
1
2
3
4
| # gateway 和 daemon 是等价的
openclaw gateway stop = openclaw daemon stop
openclaw gateway start = openclaw daemon start
openclaw gateway status = openclaw daemon status
|
🧹 手动清理清单
必须清理的目录
1
2
3
4
5
| # 主配置目录(包含所有数据)
rm -rf ~/.openclaw
# 临时文件
rm -rf /tmp/openclaw
|
可选清理的目录
1
2
3
4
5
6
7
8
9
10
11
| # 缓存(如存在)
rm -rf ~/Library/Caches/openclaw
# 日志(如存在)
rm -rf ~/Library/Logs/openclaw
# 应用支持(如安装过 App)
rm -rf ~/Library/Application\ Support/openclaw
# 保存的状态(如安装过 App)
rm -rf ~/Library/Saved\ Application\ State/ai.openclaw.*
|
环境变量清理
检查以下文件,删除 OpenClaw 相关行:
1
2
3
4
5
6
7
8
9
| # 编辑配置文件
vi ~/.zshrc # macOS 默认
vi ~/.bashrc # Linux
vi ~/.bash_profile
# 删除类似内容:
export OPENCLAW_CONFIG_PATH=...
export OPENCLAW_STATE_DIR=...
export OPENCLAW_GATEWAY_TOKEN=...
|
✅ 验证清单
卸载后验证命令
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| # 1. 命令已删除
which openclaw
# 预期:无输出
# 2. 版本命令失效
openclaw --version
# 预期:command not found
# 3. 配置目录已删除
ls -la ~/.openclaw
# 预期:No such file or directory
# 4. 无相关进程
ps aux | grep openclaw
# 预期:无相关进程(除 grep 本身)
# 5. 服务已卸载
launchctl list | grep openclaw
# 预期:无输出
# 6. 服务文件已删除
ls ~/Library/LaunchAgents/ai.openclaw.gateway.plist
# 预期:No such file or directory
|
⚠️ 常见问题
Q1: openclaw uninstall 命令不存在?
原因:版本过旧(< 2026.3.0)
解决:
1
2
3
4
5
6
7
| # 升级到最新版
npm update -g openclaw
# 或手动卸载
openclaw gateway uninstall
rm -rf ~/.openclaw
npm uninstall -g openclaw
|
Q2: 卸载后 which openclaw 仍有输出?
原因:npm 全局包未删除
解决:
1
2
| npm uninstall -g openclaw
hash -r # 刷新 shell 缓存
|
Q3: 服务无法停止?
原因:进程卡死或权限问题
解决:
1
2
3
4
5
6
7
8
9
| # 查找进程
ps aux | grep openclaw
# 强制终止
pkill -9 -f openclaw
pkill -9 -f clawd
# 然后继续卸载
openclaw gateway uninstall
|
Q4: LaunchAgent 无法卸载?
原因:服务文件损坏
解决:
1
2
3
4
| # 手动卸载
launchctl unload ~/Library/LaunchAgents/ai.openclaw.gateway.plist 2>/dev/null || true
launchctl remove ai.openclaw.gateway 2>/dev/null || true
rm ~/Library/LaunchAgents/ai.openclaw.gateway.plist
|
Q5: 如何保留配置重新安装?
解决:
1
2
3
4
5
6
7
8
9
10
| # 1. 备份
cp -r ~/.openclaw ~/openclaw-backup-$(date +%Y%m%d)
# 2. 仅卸载 npm 包(保留配置目录)
npm uninstall -g openclaw
# 3. 重新安装
npm install -g openclaw
# 4. 配置自动重用
|
Q6: 卸载后想重新安装?
解决:
1
2
3
4
5
6
7
8
9
10
11
| # 1. 安装
npm install -g openclaw
# 2. 配置
openclaw configure
# 3. 安装服务(可选)
openclaw gateway install
# 4. 启动
openclaw gateway start
|
📊 卸载方案对比
| 方案 | 命令 | 耗时 | 残留风险 | 推荐度 |
|---|
| 官方一键 | openclaw uninstall --all --yes --non-interactive && npm uninstall -g openclaw | 30 秒 | ⭐ 最低 | ⭐⭐⭐⭐⭐ |
| 分步手动 | 按步骤执行 6 步 | 2 分钟 | ⭐ 最低 | ⭐⭐⭐⭐ |
| 仅卸载服务 | openclaw uninstall --service | 10 秒 | ⭐⭐⭐ 保留数据 | ⭐⭐ |
| 手动强删 | rm -rf ~/.openclaw | 5 秒 | ⭐⭐ 可能残留服务 | ⭐⭐ |
🔐 安全提醒
- 备份优先:卸载前备份重要数据
1
2
| cp -r ~/.openclaw/workspace ~/workspace-backup
cp -r ~/.openclaw/memory ~/memory-backup
|
凭证安全:credentials/ 包含 API 密钥,确保彻底删除
平台清理:在 Feishu/Telegram 等平台移除 Bot 权限
- 预览模式:不确定时先用
--dry-run 预览
📞 需要帮助?
- 官方文档:https://docs.openclaw.ai
- 卸载文档:https://docs.openclaw.ai/cli/uninstall
- GitHub:https://github.com/openclaw/openclaw
- Discord:https://discord.com/invite/clawd
文档版本:1.1
适用于:openclaw@2026.3.8+