问题描述
如果你的 openclaw 在安装过程中提示:
Gateway service not installed.
Gateway service install failed: Error: systemctl enable failed: Failed to enable unit:
Tip: rerun
openclaw gateway installafter fixing the error.
重复安装的时候还是提示:
Gateway install failed: Error: systemctl enable failed: Failed to enable unit: Unit file openclaw-gateway.service does not exist.
大概率是遇到bug了,该 BUG 可能影响全部的Ubuntu系统: Issues描述
创建 openclaw gateway 服务
这时候我们可以尝试手动创建 openclaw gateway 服务来解决
首先确认一下问题:
systemctl --user daemon-reload
如果提示:
Failed to connect to bus: No medium found
则执行一下步骤:
export XDG_RUNTIME_DIR=/run/user/$(id -u)
export DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus"
systemctl --user daemon-reload
如果没有提示,那就是没问题,就继续往下。
执行
systemctl --user is-enabled openclaw-gateway.service
如果提示 not-found ,那我们就继续以下修复步骤:
寻找 openclaw 所在位置
which openclaw
会打印一个路径如下:
/usr/bin/openclaw
我们留着。
sudo mkdir -p /root/.config/systemd/user
sudo nano /root/.config/systemd/user/openclaw-gateway.service
复制以下内容:
注:用你前面查找到的 openclaw 的实际路径替换下面的 /usr/bin/openclaw
[Unit]
Description=OpenClaw Gateway
After=network.target
[Service]
ExecStart=/usr/bin/openclaw gateway run
Restart=on-failure
RestartSec=5
[Install]
WantedBy=default.target
CTRL+X保存
重新加载一下服务:
systemctl --user daemon-reload
systemctl --user enable --now openclaw-gateway.service
systemctl --user status openclaw-gateway.service
显示 active (running) ,好了,现在可以用你的本地浏览器打开了。
访问
如果你连接的的是不带 UI 的的 ubuntu,可以在你的 windows 下使用终端管理员运行:
IP和ubuntu用户名替换成你自己的。
ssh -N -L 18789:127.0.0.1:18789 ubuntu@192.168.1.199
然后就可以在本地浏览器打开 http://localhost:18789/#token=[yourtoken] 运行啦~
参考链接
https://github.com/openclaw/openclaw/issues/33633
https://github.com/openclaw/openclaw/issues/33512
https://www.reddit.com/r/openclaw/comments/1rjpmu0/installation_is_hell