fix(daemon): avoid freezing Windows PATH in task scripts (#39139, thanks @Narcooo)

Co-authored-by: majx_mac <mjxnarco@pku.edu.cn>
This commit is contained in:
Peter Steinberger
2026-03-07 21:15:01 +00:00
parent f51cac277c
commit b9dd6e99b6
7 changed files with 74 additions and 9 deletions

View File

@@ -268,7 +268,7 @@ describe("buildServiceEnvironment", () => {
});
expect(env.HOME).toBe("/home/user");
if (process.platform === "win32") {
expect(env.PATH).toBe("");
expect(env).not.toHaveProperty("PATH");
} else {
expect(env.PATH).toContain("/usr/bin");
}
@@ -331,6 +331,20 @@ describe("buildServiceEnvironment", () => {
expect(env.http_proxy).toBe("http://proxy.local:7890");
expect(env.all_proxy).toBe("socks5://proxy.local:1080");
});
it("omits PATH on Windows so Scheduled Tasks can inherit the current shell path", () => {
const env = buildServiceEnvironment({
env: {
HOME: "C:\\Users\\alice",
PATH: "C:\\Windows\\System32;C:\\Tools\\rg",
},
port: 18789,
platform: "win32",
});
expect(env).not.toHaveProperty("PATH");
expect(env.OPENCLAW_WINDOWS_TASK_NAME).toBe("OpenClaw Gateway");
});
});
describe("buildNodeServiceEnvironment", () => {