mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-28 02:12:07 +00:00
Add loginctl enable-linger and XDG_RUNTIME_DIR recovery hints to the generic (non-WSL) systemd unavailable error path, helping users on SSH/headless servers diagnose and fix the issue without a desktop session. Fixes #11805 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
37 lines
1.6 KiB
TypeScript
37 lines
1.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { formatCliCommand } from "../cli/command-format.js";
|
|
import { isSystemdUnavailableDetail, renderSystemdUnavailableHints } from "./systemd-hints.js";
|
|
|
|
describe("isSystemdUnavailableDetail", () => {
|
|
it("matches systemd unavailable error details", () => {
|
|
expect(
|
|
isSystemdUnavailableDetail("systemctl --user unavailable: Failed to connect to bus"),
|
|
).toBe(true);
|
|
expect(
|
|
isSystemdUnavailableDetail(
|
|
"systemctl not available; systemd user services are required on Linux.",
|
|
),
|
|
).toBe(true);
|
|
expect(isSystemdUnavailableDetail("permission denied")).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("renderSystemdUnavailableHints", () => {
|
|
it("renders WSL2-specific recovery hints", () => {
|
|
expect(renderSystemdUnavailableHints({ wsl: true })).toEqual([
|
|
"WSL2 needs systemd enabled: edit /etc/wsl.conf with [boot]\\nsystemd=true",
|
|
"Then run: wsl --shutdown (from PowerShell) and reopen your distro.",
|
|
"Verify: systemctl --user status",
|
|
]);
|
|
});
|
|
|
|
it("renders generic Linux recovery hints outside WSL", () => {
|
|
expect(renderSystemdUnavailableHints()).toEqual([
|
|
"systemd user services are unavailable; install/enable systemd or run the gateway under your supervisor.",
|
|
"On a headless server (SSH/no desktop session): run `loginctl enable-linger` to persist your systemd user session across logins.",
|
|
"Also ensure XDG_RUNTIME_DIR is set: `export XDG_RUNTIME_DIR=/run/user/$(id -u)`, then retry.",
|
|
`If you're in a container, run the gateway in the foreground instead of \`${formatCliCommand("openclaw gateway")}\`.`,
|
|
]);
|
|
});
|
|
});
|