fix(doctor): honor WSL env overrides in hints · openclaw/openclaw@eb07ba5
vincentkoc
·
2026-06-18
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -41,6 +41,23 @@ describe("buildGatewayRuntimeHints", () => {
|
41 | 41 | ]); |
42 | 42 | }); |
43 | 43 | |
| 44 | +it("uses the provided env when rendering WSL systemd recovery hints", () => { |
| 45 | +const hints = buildGatewayRuntimeHints( |
| 46 | +{ |
| 47 | +status: "unknown", |
| 48 | +detail: "System has not been booted with systemd as init system", |
| 49 | +}, |
| 50 | +{ platform: "linux", env: { WSL_DISTRO_NAME: "Ubuntu" } }, |
| 51 | +); |
| 52 | + |
| 53 | +expect(hints).toContain( |
| 54 | +"WSL2 needs systemd enabled: edit /etc/wsl.conf with [boot]\\nsystemd=true", |
| 55 | +); |
| 56 | +expect(hints).toContain("Then run: wsl --shutdown (from PowerShell) and reopen your distro."); |
| 57 | +expect(hints).toContain("Verify: systemctl --user status"); |
| 58 | +expect(hints.join("\n")).not.toContain("systemd user services are unavailable"); |
| 59 | +}); |
| 60 | + |
44 | 61 | it("does not warn for normal systemd cgroup metrics", () => { |
45 | 62 | expect( |
46 | 63 | buildGatewayRuntimeHints( |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -55,7 +55,7 @@ export function buildGatewayRuntimeHints(
|
55 | 55 | if (platform === "linux" && isSystemdUnavailableDetail(runtime.detail)) { |
56 | 56 | hints.push( |
57 | 57 | ...renderSystemdUnavailableHints({ |
58 | | -wsl: isWSLEnv(), |
| 58 | +wsl: isWSLEnv(env), |
59 | 59 | kind: classifySystemdUnavailableDetail(runtime.detail), |
60 | 60 | container, |
61 | 61 | }), |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -69,6 +69,11 @@ describe("wsl detection", () => {
|
69 | 69 | expect(isWSLEnv()).toBe(true); |
70 | 70 | }); |
71 | 71 | |
| 72 | +it("detects WSL from an explicit env map", () => { |
| 73 | +expect(isWSLEnv({ WSL_DISTRO_NAME: "Ubuntu" })).toBe(true); |
| 74 | +expect(isWSLEnv({})).toBe(false); |
| 75 | +}); |
| 76 | + |
72 | 77 | it("reads /proc/version for sync WSL detection when env vars are absent", () => { |
73 | 78 | readFileSyncMock.mockReturnValueOnce("Linux version 6.6.0-1-microsoft-standard-WSL2"); |
74 | 79 | expect(isWSLSync()).toBe(true); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -11,8 +11,8 @@ export function resetWSLStateForTests(): void {
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** Detects WSL from environment variables without touching the filesystem. */ |
14 | | -export function isWSLEnv(): boolean { |
15 | | -if (process.env.WSL_INTEROP || process.env.WSL_DISTRO_NAME || process.env.WSLENV) { |
| 14 | +export function isWSLEnv(env: Record<string, string | undefined> = process.env): boolean { |
| 15 | +if (env.WSL_INTEROP || env.WSL_DISTRO_NAME || env.WSLENV) { |
16 | 16 | return true; |
17 | 17 | } |
18 | 18 | return false; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。