The best way to control Claude Code, Codex and more from any computer or phone
fix(server): restore PR detection without HOME (#4985)
Wout Stiens committed
Jul 30, 2026 at 18:17 UTC
edc503a7a8ea5284a2711981c1a10a6b9999f5e4
2 files changed
+59
apps/server/src/os-jank.test.ts
new
+40
@@ -0,0 +1,40 @@
1
+import * as NodeOS from "node:os";
2
+import { assert, it } from "vite-plus/test";
3
+
4
+import { hydratePosixHome } from "./os-jank.ts";
5
+
6
+it("hydrates HOME for minimal service environments from the user account", () => {
7
+ const env: NodeJS.ProcessEnv = {};
8
+
9
+ hydratePosixHome(env);
10
+
11
+ assert.equal(env.HOME, NodeOS.userInfo().homedir);
12
+});
13
+
14
+it("hydrates HOME independently of a blank process HOME", () => {
15
+ const originalHome = process.env.HOME;
16
+ const env: NodeJS.ProcessEnv = { HOME: " " };
17
+
18
+ try {
19
+ process.env.HOME = " ";
20
+ hydratePosixHome(env);
21
+ } finally {
22
+ if (originalHome === undefined) {
23
+ delete process.env.HOME;
24
+ } else {
25
+ process.env.HOME = originalHome;
26
+ }
27
+ }
28
+
29
+ assert.equal(env.HOME, NodeOS.userInfo().homedir);
30
+});
31
+
32
+it("preserves an explicitly configured HOME", () => {
33
+ const env: NodeJS.ProcessEnv = { HOME: "/custom/home" };
34
+
35
+ hydratePosixHome(env, () => {
36
+ throw new Error("HOME lookup should not run");
37
+ });
38
+
39
+ assert.equal(env.HOME, "/custom/home");
40
+});
apps/server/src/os-jank.ts
+19
@@ -36,6 +36,18 @@ function hydratePosixPath(env: NodeJS.ProcessEnv, platform: NodeJS.Platform): vo
36
}
37
}
38
39
+export function hydratePosixHome(
40
+ env: NodeJS.ProcessEnv,
41
+ resolveHomeDir = () => NodeOS.userInfo().homedir,
42
+): void {
43
+ if ((env.HOME?.trim() ?? "").length > 0) return;
44
+
45
+ const homeDir = resolveHomeDir();
46
+ if (homeDir.length > 0) {
47
+ env.HOME = homeDir;
48
+ }
49
+}
50
+
51
export const fixPath = Effect.fn("fixPath")(function* (): Effect.fn.Return<
52
void,
53
never,
@@ -63,6 +75,13 @@ export const fixPath = Effect.fn("fixPath")(function* (): Effect.fn.Return<
75
76
if (platform !== "darwin" && platform !== "linux") return;
77
78
+ yield* Effect.sync(() => hydratePosixHome(env)).pipe(
79
+ Effect.catchDefect((defect) =>
80
+ Effect.sync(() => {
81
+ logPathHydrationWarning("Failed to hydrate HOME from the user account.", defect);
82
+ }),
83
+ ),
84
+ );
85
yield* Effect.sync(() => hydratePosixPath(env, platform)).pipe(
86
Effect.catchDefect((defect) =>
87
Effect.sync(() => {