一、彻底清理 OpenClaw

在 WSL 里依次执行 :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 第一步:官方卸载命令(停服务+删二进制)
openclaw gateway stop
openclaw uninstall --all --yes --non-interactive

# 第二步:删所有残留目录
rm -rf ~/.openclaw ~/.clawdbot ~/.moltbot ~/.molthub ~/molthub-cache
rm -rf ~/.local/share/openclaw/

# 第三步:删 npm 全局包
npm uninstall -g openclaw
npm uninstall -g moltbot
npm uninstall -g clawdbot

# 验证干净了
which openclaw # 应该无输出
ls ~/.openclaw # 应该报错不存在

如果遇到顽固的删不了,则依次运行:

1
2
3
4
5
6
7
sudo rm /usr/local/bin/openclaw

sudo rm -f /usr/local/bin/openclaw
sudo rm -f /usr/local/bin/openclaw-gateway
sudo rm -f /usr/local/bin/clawdbot

which openclaw # 无输出就干净了

二、重装:

1
npm install -g openclaw

但是主程序会在根目录的 .npm-global

三、重装后 openclaw.json 配置 Qwen API

需要手动在根目录新建文件夹,用鼠标新建也可以:

1
2
3
4
5
6
7
8
# 创建配置目录
mkdir -p ~/.openclaw
mkdir -p ~/.openclaw/workspace

# 创建 openclaw.json
nano ~/.openclaw/openclaw.json
nano ~/.openclaw/workspace/AGENTS.md
nano ~/.openclaw/workspace/SOUL.md

复制到 openclaw.json 里面:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{
"models": {
"providers": {
"qwen": {
"baseUrl": "https://dashscope.aliyuncs.com/compatible-mode/v1",
"api": "openai-completions",
"apiKey": "你的DashScope API Key",
"models": [
{
"id": "qwen-plus",
"name": "qwen-plus",
"reasoning": false,
"input": ["text"],
"cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 },
"contextWindow": 131072,
"maxTokens": 8192
}
]
}
}
},
"agents": {
"defaults": {
"model": { "primary": "qwen/qwen-plus" }
}
},
"gateway": {
"mode": "local",
"auth": { "token": "mytoken---" }
},
"env": {
"vars": {
"SEARXNG_URL": "http://127.0.0.1:8888"
}
},
"tools": {
"web": {
"search": { "enabled": false },
"fetch": { "enabled": false }
}
}
}

DashScope API Key 在 dashscope.console.aliyun.com 里申请。

最后,启动:

1
openclaw gateway start

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.