openclaw屎山代码发力!

2026-04-11 15:011阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐
问题描述:

Error: systemctl is-enabled unavailable: Command failed: systemctl --user is-enabled openclaw-gateway.service

鏖战三个小时未能安装成功
gpt、grok、gemini都搜不出个所以然,手动google直接检索到有用的Github issue

github.com/openclaw/openclaw

openclaw gateway status fails on EC2/headless servers due to missing user-level systemd

已打开 10:33AM - 08 Feb 26 UTC niceysam bug

# Issue: `openclaw gateway status` fails on EC2/headless servers due to missing …user-level systemd ## Summary On headless EC2 instances (and similar server environments), `openclaw gateway status` and `openclaw gateway install` fail with "Failed to connect to bus: No medium found" because user-level systemd (`systemctl --user`) is unavailable by default. ## Environment - **OS:** Amazon Linux 2023 (6.1.159-182.297.amzn2023.x86_64) - **OpenClaw:** 2026.2.6-3 - **Node.js:** v22.22.0 - **Architecture:** x86_64 EC2 instance ## Problem ### Error Message ``` Gateway service check failed: Error: systemctl --user unavailable: Failed to connect to bus: No medium found Runtime: unknown (Error: systemctl --user unavailable: Failed to connect to bus: No medium found) systemd user services unavailable. systemd user services are unavailable; install/enable systemd or run the gateway under your supervisor. ``` ### Root Cause On EC2 and headless servers: 1. User-level systemd requires a D-Bus session bus 2. D-Bus session bus requires `XDG_RUNTIME_DIR` to be set 3. SSH sessions don't automatically set `XDG_RUNTIME_DIR` 4. `loginctl enable-linger` needs to be enabled for the user ## Current Workaround ```bash # 1. Enable linger for user persistence sudo loginctl enable-linger $(whoami) # 2. Set XDG_RUNTIME_DIR (add to ~/.bashrc) export XDG_RUNTIME_DIR=/run/user/$(id -u) # 3. Now openclaw gateway install works openclaw gateway install --force ``` ## Suggested Improvements ### Option A: Better Error Message + Documentation - Detect the missing `XDG_RUNTIME_DIR` scenario - Provide actionable fix instructions in the error message: ``` systemctl --user unavailable: D-Bus session bus not found. On headless servers (EC2, etc.), run: sudo loginctl enable-linger $(whoami) export XDG_RUNTIME_DIR=/run/user/$(id -u) Then retry: openclaw gateway install ``` ### Option B: Support System-Level systemd Service - Add `--system` flag to `openclaw gateway install` - Install to `/etc/systemd/system/openclaw.service` instead of user-level - Useful for servers where system-level services are preferred ### Option C: Auto-detect and Set XDG_RUNTIME_DIR - If `XDG_RUNTIME_DIR` is unset but `/run/user/<uid>` exists, set it automatically - Would fix the issue transparently for most cases ## Logs ```json {"0":"Gateway service check failed: Error: systemctl --user unavailable: Failed to connect to bus: No medium found","_meta":{"logLevelName":"ERROR"},"time":"2026-02-08T10:20:22.063Z"} {"0":"systemd user services unavailable.","_meta":{"logLevelName":"ERROR"},"time":"2026-02-08T10:21:23.811Z"} ``` ## Related This likely affects all headless Linux deployments: - AWS EC2 - GCP Compute Engine - Azure VMs - Docker containers (already mentioned in current error message) - Any server accessed via SSH without a desktop session

原来是引导程序有缺陷
有人提了pr,但是过了五天没一个人理

github.com/openclaw/openclaw

fix: improve systemd hints for headless/EC2 servers (#28069)

maindsantoreis:fix/systemd-headless-hints 已打开 12:45AM - 27 Feb 26 UTC dsantoreis +37 -7

## Summary Improves the error message and diagnostic output when `openclaw gate…way status` and `openclaw gateway install` fail on headless servers (EC2, VPS, etc.) due to missing user-level systemd. Closes #11805 ## Changes - **Actionable fix instructions**: Instead of the generic "systemd user services are unavailable", the error now tells users exactly what to run: ``` sudo loginctl enable-linger $(whoami) export XDG_RUNTIME_DIR=/run/user/$(id -u) ``` - **Environment diagnostics**: Detects and reports missing `XDG_RUNTIME_DIR` and `DBUS_SESSION_BUS_ADDRESS` — the two most common causes on headless servers - **Pattern detection**: Added `no medium found` to the recognized error patterns in `isSystemdUnavailableDetail()` - **Alternative paths**: Suggests process supervisors (supervisord, system-level systemd) as alternatives ## Before ``` systemd user services are unavailable; install/enable systemd or run the gateway under your supervisor. ``` ## After ``` systemd user services are unavailable. Diagnostics: XDG_RUNTIME_DIR is not set. This is required for systemd user services. Fix: export XDG_RUNTIME_DIR=/run/user/$(id -u) DBUS_SESSION_BUS_ADDRESS is not set. The D-Bus session bus is needed for systemctl --user. On headless servers (EC2, VPS, etc.), run: sudo loginctl enable-linger $(whoami) export XDG_RUNTIME_DIR=/run/user/$(id -u) # add to ~/.bashrc for persistence Then retry: openclaw gateway install --force ``` ## Testing - No logic changes to service management — only error message improvements - Added exported `diagnoseSystemdEnvironment()` function for potential reuse - All existing code paths preserved

====更新====
这里说下我总结出来的一套更稳定的安装流程。

#安装本体,不使用引导程序 #只能使用npm安装,pnpm安装会因为路径错误而导致无法使用webui(dashboard) curl -fsSL https://openclaw.ai/install.sh | bash -s -- --no-onboard #运行修复程序,然后根据提示进行修复 openclaw doctor #最后运行引导程序(到了注册服务这一步可以跳过/重启) #引导程序本质就是对 ~/.openclaw/openclaw.json 进行修改,且引导程序使用非常不便 openclaw onboard

安装完成之后,需要给予agent更高的工具权限,不然啥事都干不了。
不要再webui中修改,因为按钮是假的,点了没效果。
在~/.openclaw/openclaw.json中进行修改,具体参考:

OpenClaw

工具 - OpenClaw

如果你发现在telegram中,想切换模型时,只有根据引导程序配置的那一个模型可选,那是因为引导程序自作主张限制了~/.openclaw/openclaw.json中agent配置项下的允许模型列表,参考以下文档进行修改:

OpenClaw

​通过 models.providers 配置的提供商(自定义/基础 URL) - 模型提供商 - OpenClaw

看到Openclaw的repo:
image496×131 6.73 KB
屎山已经有了4.9k的pr
给我逗笑了

网友解答:
--【壹】--:

有些错误其实去搜他的文档还是可以很好解决的 最反常规的就是他的那个web端的配置ui 我挠破头都没看懂是给哪个外星人开发使用的


--【贰】--:

web端配置项我是真看不明白


--【叁】--:

装3.1版本,再升级


--【肆】--:

试过了,不行
刚刚通过openclaw doctor修好了


--【伍】--:

你在容器里面安装吗,有没有可能没有 systemd


--【陆】--:

真的要点赞,这玩意bug太多了!!!!


--【柒】--:

我也遇到这个,所以我一直使用手动的sudo systemctl restart来重启。


--【捌】--:

这玩意看着火,但是出了问题你在网上都找不到解决办法


--【玖】--:

直接把仓库链接丢给codx装


--【拾】--:

哈哈哈 我当时以为弄出这个web来接下来就不需要操作文件优雅的使用龙虾了,结果迎接我的却是一坨大的


--【拾壹】--:

为了那个web配置了反代,web报的其他错误全是让cc帮我解决的


--【拾贰】--:

我用 doctor 修不好,问 gemini 改了几次修好的


--【拾叁】--:

卧槽我还在以为自己问题,一搜就有答案的感觉太棒了佬友


--【拾肆】--:

当然是有systemd的


--【拾伍】--:

这玩意 bug 比代码都多,纯 vibe 的质量太差了


--【拾陆】--:

真是中 啊


--【拾柒】--:

这种东西等个半年就会大浪淘金出真正好用的了,现在还是算了


--【拾捌】--:

Github issue里的方法如果你试了没用的话
可以试试用openclaw docker修复


--【拾玖】--:

我今天升级版本也遇到了,执行这个就可以了
sudo loginctl enable-linger ubuntu
systemctl --user daemon-reload