🧹 macOS 彻底卸载 OpenClaw 完整指南(2026 最新版)
适用场景 :重装失败、服务残留、环境冲突、彻底清理
警告 :卸载将永久删除 所有配置、技能、对话记录!操作前请备份~/.openclaw/workspace。
✅ 一、官方推荐方法(首选)
如果 openclaw 命令仍可用,直接使用内置卸载器:
bash
# 交互式卸载(会确认)
openclaw uninstall
# 非交互式(自动化脚本用)
openclaw uninstall --all --yes --non-interactive
✅ 该命令会自动:
- 停止 Gateway 服务
- 移除 launchd 服务注册
- 删除
~/.openclaw目录- 卸载 npm 全局包
🔧 二、手动卸载步骤(当 CLI 已损坏或命令丢失)
步骤 1:停止所有 OpenClaw 进程
bash
# 停止 Gateway 服务
launchctl bootout gui/$UID/bot.molt.gateway 2>/dev/null || echo "Gateway 未运行"
# 强制杀死残留进程
pkill -f openclaw || echo "无残留进程"
步骤 2:移除 macOS 启动代理(launchd)
bash
# 删除服务 plist 文件
rm -f ~/Library/LaunchAgents/bot.molt.gateway.plist
rm -f ~/Library/LaunchAgents/com.openclaw.* # 兼容旧版
步骤 3:删除核心数据目录
bash
# 删除工作区、配置、缓存(⚠️ 不可恢复!)
rm -rf ~/.openclaw
步骤 4:卸载 npm 全局包
bash
# 卸载主程序
npm uninstall -g openclaw
# 清理可能残留的微信插件
npm uninstall -g @tencent-weixin/openclaw-weixin-cli
步骤 5:清理 Shell 配置(可选)
检查是否添加了自动启动:
bash
# 检查 zsh
grep -n "openclaw" ~/.zshrc ~/.zprofile 2>/dev/null
# 检查 bash
grep -n "openclaw" ~/.bashrc ~/.bash_profile 2>/dev/null
如有相关行(如 eval "$(openclaw init -)"),手动删除。
🔍 三、验证是否卸载干净
bash
# 1. 检查进程
ps aux | grep openclaw # 应无输出
# 2. 检查端口(默认 8192)
lsof -i :8192 # 应无输出
# 3. 检查目录
ls ~/.openclaw # 应提示 "No such file or directory"
# 4. 检查 npm 包
npm list -g --depth=0 | grep openclaw # 应无输出
⚠️ 四、常见问题处理
| 问题 | 解决方案 |
|---|---|
launchctl bootout 报错 No such process |
忽略,说明服务已停止 |
| 重新安装后仍报端口占用 | 执行 sudo lsof -i :8192 查杀残留进程 |
| 卸载后终端提示 command not found | 正常现象,说明 CLI 已移除 |
执行完以上步骤,你的 macOS 将完全清除 OpenClaw 所有痕迹,可安全重装或切换其他 AI 工具。