@devries-cameron20 / t3code-1 / commits / a7c22f12b7
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): the background service picks up JAVA_HOME from the login shell (#22856)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Theo Browne committed Oct 21, 2026 at 06:18 UTC a7c22f12b7f62dbc859749c73ec6f9c031af71d7
2 files changed +46 -1
apps/server/src/os-jank.test.ts
+40
@@ -96,6 +96,46 @@ effectIt.effect("keeps mise's PATH record with the login shell PATH", () =>
96 ),
97 );
98
99 +effectIt.effect("hydrates a missing JAVA_HOME from the login shell and keeps an explicit one", () =>
100 + Effect.acquireUseRelease(
101 + Effect.sync(() =>
102 + vi
103 + .spyOn(NodeChildProcess, "execFileSync")
104 + .mockReturnValue(
105 + [
106 + "__T3CODE_ENV_PATH_START__",
107 + "/opt/homebrew/bin",
108 + "__T3CODE_ENV_PATH_END__",
109 + "__T3CODE_ENV_JAVA_HOME_START__",
110 + "/opt/homebrew/opt/openjdk@17",
111 + "__T3CODE_ENV_JAVA_HOME_END__",
112 + ].join("\n"),
113 + ),
114 + ),
115 + () =>
116 + Effect.gen(function* () {
117 + const missing: NodeJS.ProcessEnv = { SHELL: "/bin/zsh", PATH: "/usr/bin" };
118 + const explicit: NodeJS.ProcessEnv = {
119 + SHELL: "/bin/zsh",
120 + PATH: "/usr/bin",
121 + JAVA_HOME: "/custom/jdk",
122 + };
123 +
124 + for (const env of [missing, explicit]) {
125 + yield* fixPath().pipe(
126 + Effect.provideService(HostProcess.Platform, "darwin"),
127 + Effect.provideService(HostProcess.Environment, env),
128 + Effect.provide(NodeServices.layer),
129 + );
130 + }
131 +
132 + assert.equal(missing.JAVA_HOME, "/opt/homebrew/opt/openjdk@17");
133 + assert.equal(explicit.JAVA_HOME, "/custom/jdk");
134 + }),
135 + (probe) => Effect.sync(() => probe.mockRestore()),
136 + ),
137 +);
138 +
139 effectIt.effect("replaces a Path-spelled Windows PATH instead of adding a second key", () =>
140 Effect.gen(function* () {
141 const env: NodeJS.ProcessEnv = { Path: "C:\\Windows" };
apps/server/src/os-jank.ts
+6 -1
@@ -25,7 +25,7 @@ function hydratePosixPath(env: NodeJS.ProcessEnv, platform: NodeJS.Platform): vo
25 // mise's record of the PATH entries it added. It must travel with the
26 // shell's PATH, or `mise x` can rebuild PATH behind a same-named wrapper
27 // (`exec mise x claude -- claude`) that then re-runs itself forever.
28 - shellEnvironment = readEnvironmentFromLoginShell(shell, ["PATH", "__MISE_DIFF"]);
28 + shellEnvironment = readEnvironmentFromLoginShell(shell, ["PATH", "__MISE_DIFF", "JAVA_HOME"]);
29 } catch (error) {
30 logPathHydrationWarning(`Failed to read PATH from login shell ${shell}.`, error);
31 }
@@ -42,6 +42,11 @@ function hydratePosixPath(env: NodeJS.ProcessEnv, platform: NodeJS.Platform): vo
42 if (shellPath && shellEnvironment.__MISE_DIFF) {
43 env.__MISE_DIFF = shellEnvironment.__MISE_DIFF;
44 }
45 + // Android SDK tools are Java programs. A keg-only JDK (Homebrew's openjdk)
46 + // is only reachable through the JAVA_HOME the shell profile sets.
47 + if (!env.JAVA_HOME && shellEnvironment.JAVA_HOME) {
48 + env.JAVA_HOME = shellEnvironment.JAVA_HOME;
49 + }
50 }
51
52 export function hydratePosixHome(