WSL2用npm安装的openclaw,无法正常使用openclaw gateway start启动服务的问题
问题描述
当使用start命令启动时报错
bash
systemd user services unavailable.
WSL2 needs systemd enabled: edit /etc/wsl.conf with [boot]
systemd=true
Then run: wsl --shutdown (from PowerShell) and reopen your distro
执行systemctl --user status时报错
bash
systemctl --user status
Failed to connect to bus: No such file or directory
解决方案
按提示通过多次尝试仍然不能解决问题
最终我查了一个wsl2的内核版本
bash
wsl --version
WSL 版本: 2.5.10.0
内核版本: 6.6.87.2-1
WSLg 版本: 1.0.66
MSRDC 版本: 1.2.6074
Direct3D 版本: 1.611.1-81528511
DXCore 版本: 10.0.26100.1-240331-1435.ge-release
Windows: 10.0.26200.8039
尝试有没有更新版
bash
wsl --update
正在检查更新。
正在更新适用于 Linux 的 Windows 子系统: 2.6.3。
新版本是2.6.3
于是就先更新wsl子系统内核再说, 使用wsl --update直接更新3小时才下载到33%,很慢
最终通过github下载安装的,下载链接wsl.2.6.3.0.x64.msi,顺便提供一下WSL官方项目地址:github.com/microsoft/WSL
下载完成后双击安装
powershell 执行 wsl启动之前的linux子系统
进入子系统执行
bash
openclaw gateway start
报错
bash
Gateway service disabled.
Start with: openclaw gateway install
Start with: openclaw gateway
Start with: systemctl --user start openclaw-gateway.service
启动失败,于是执行
bash
systemctl --user start openclaw-gateway.service
报
bash
Failed to start openclaw-gateway.service: Unit openclaw-gateway.service not found.
怀疑是之前安装的openclaw gateway未正常写入启动文件,于是重装openclaw gateway
bash
openclaw gateway uninstall
openclaw gateway install
显示
bash
Installed systemd service: ...
看起来成功了
执行
bash
openclaw gateway start
显示
bash
Restarted systemd service: openclaw-gateway.service
浏览器中打开http://127.0.0.1:18789/
正常进入,问题解决。