fix: Claude and Codex no longer time out behind mise wrappers (#19340)

Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Theo BrowneandClaude Opus 5.5 authored and GitHub committed 2026-10-14 02:25:39 -07:00
1 parent 9a01524f3f
commit 7ee2839cb5
6 files changed
+73 -14

No files matched your search

@@ -367,6 +367,27 @@ describe("DesktopShellEnvironment", () => {
}),
);
it.effect("keeps mise's PATH record with the login shell PATH", () =>
Effect.gen(function* () {
const env: NodeJS.ProcessEnv = {
SHELL: "/bin/bash",
PATH: "/usr/bin",
};
yield* runShellEnvironment({
env,
platform: "linux",
handler: () =>
envOutput({
PATH: "/home/me/.local/bin:/mise/installs/claude/latest:/mise/shims",
__MISE_DIFF: "mise-diff",
}),
});
assert.equal(env.__MISE_DIFF, "mise-diff");
}),
);
it.effect("falls back to launchctl PATH on macOS when shell probing does not return one", () =>
Effect.gen(function* () {
const env: NodeJS.ProcessEnv = {
@@ -87,6 +87,7 @@ const LOGIN_SHELL_ENV_NAMES = [
"XDG_SESSION_TYPE",
"WAYLAND_DISPLAY",
"T3CODE_TELEMETRY_ENABLED",
"__MISE_DIFF",
] as const;
const WINDOWS_PROFILE_ENV_NAMES = ["PATH", "FNM_DIR", "FNM_MULTISHELL_PATH"] as const;
const LOCALE_ENV_NAMES = ["LANG", "LC_ALL", "LC_CTYPE"] as const;
@@ -433,6 +434,10 @@ const installPosixEnvironment = Effect.fn("desktop.shellEnvironment.installPosix
"XDG_CURRENT_DESKTOP",
"XDG_SESSION_DESKTOP",
"XDG_SESSION_TYPE",
// mise's record of the PATH entries it added. It must travel with the
// shell's PATH, or `mise x` can rebuild PATH behind a same-named wrapper
// (`exec mise x claude -- claude`) that then re-runs itself forever.
"__MISE_DIFF",
] as const;
for (const name of shellPreferredEnvNames) {
if (shellEnvironment[name]) {
+32
View File
@@ -98,6 +98,38 @@ effectIt.effect("hydrates PATH when the desktop handoff is absent", () =>
),
);
effectIt.effect("keeps mise's PATH record with the login shell PATH", () =>
Effect.acquireUseRelease(
Effect.sync(() =>
vi
.spyOn(NodeChildProcess, "execFileSync")
.mockReturnValue(
[
"__T3CODE_ENV_PATH_START__",
"/home/me/.local/bin:/mise/installs/claude/latest:/mise/shims",
"__T3CODE_ENV_PATH_END__",
"__T3CODE_ENV___MISE_DIFF_START__",
"mise-diff",
"__T3CODE_ENV___MISE_DIFF_END__",
].join("\n"),
),
),
() =>
Effect.gen(function* () {
const env: NodeJS.ProcessEnv = { SHELL: "/bin/bash", PATH: "/usr/bin" };
yield* fixPath().pipe(
Effect.provideService(HostProcess.Platform, "linux"),
Effect.provideService(HostProcess.Environment, env),
Effect.provide(NodeServices.layer),
);
assert.equal(env.__MISE_DIFF, "mise-diff");
}),
(probe) => Effect.sync(() => probe.mockRestore()),
),
);
effectIt.effect("repairs Windows PATH even when the desktop marks it prepared", () =>
Effect.gen(function* () {
const env: NodeJS.ProcessEnv = { PATH: "C:\\Windows" };
+11 -4
View File
@@ -2,7 +2,7 @@ import * as HostProcess from "@t3tools/shared/HostProcess";
import {
listLoginShellCandidates,
mergePathEntries,
readPathFromLoginShell,
readEnvironmentFromLoginShell,
readPathFromLaunchctl,
resolveWindowsEnvironment,
} from "@t3tools/shared/shell";
@@ -18,22 +18,29 @@ function logPathHydrationWarning(message: string, error?: unknown): void {
}
function hydratePosixPath(env: NodeJS.ProcessEnv, platform: NodeJS.Platform): void {
let shellPath: string | undefined;
let shellEnvironment: Partial<Record<string, string>> = {};
for (const shell of listLoginShellCandidates(platform, env.SHELL)) {
try {
shellPath = readPathFromLoginShell(shell);
// mise's record of the PATH entries it added. It must travel with the
// shell's PATH, or `mise x` can rebuild PATH behind a same-named wrapper
// (`exec mise x claude -- claude`) that then re-runs itself forever.
shellEnvironment = readEnvironmentFromLoginShell(shell, ["PATH", "__MISE_DIFF"]);
} catch (error) {
logPathHydrationWarning(`Failed to read PATH from login shell ${shell}.`, error);
}
if (shellPath) break;
if (shellEnvironment.PATH) break;
}
const shellPath = shellEnvironment.PATH;
const launchctlPath = platform === "darwin" && !shellPath ? readPathFromLaunchctl() : undefined;
const mergedPath = mergePathEntries(shellPath ?? launchctlPath, env.PATH, platform);
if (mergedPath) {
env.PATH = mergedPath;
}
if (shellPath && shellEnvironment.__MISE_DIFF) {
env.__MISE_DIFF = shellEnvironment.__MISE_DIFF;
}
}
export function hydratePosixHome(
+4 -3
View File
@@ -22,7 +22,6 @@ import {
readEnvironmentFromLoginShell,
readEnvironmentFromWindowsShell,
readPathFromLaunchctl,
readPathFromLoginShell,
resolveCommandPath,
resolveKnownWindowsCliDirs,
resolveSpawnCommand,
@@ -57,7 +56,7 @@ const recordCommandTrace = Effect.fnUntraced(function* <A, E, R>(effect: Effect.
return { result, spans };
});
describe("readPathFromLoginShell", () => {
describe("readEnvironmentFromLoginShell probe", () => {
it("uses a shell-agnostic printenv PATH probe", () => {
const execFile = vi.fn<
(
@@ -67,7 +66,9 @@ describe("readPathFromLoginShell", () => {
) => string
>(() => "__T3CODE_ENV_PATH_START__\n/a:/b\n__T3CODE_ENV_PATH_END__\n");
expect(readPathFromLoginShell("/opt/homebrew/bin/fish", execFile)).toBe("/a:/b");
expect(readEnvironmentFromLoginShell("/opt/homebrew/bin/fish", ["PATH"], execFile).PATH).toBe(
"/a:/b",
);
expect(execFile).toHaveBeenCalledTimes(1);
const firstCall = execFile.mock.calls[0] as
-7
View File
@@ -172,13 +172,6 @@ export function listLoginShellCandidates(
return candidates;
}
export function readPathFromLoginShell(
shell: string,
execFile: ExecFileSyncLike = NodeChildProcess.execFileSync,
): string | undefined {
return readEnvironmentFromLoginShell(shell, ["PATH"], execFile).PATH;
}
export function readPathFromLaunchctl(
execFile: ExecFileSyncLike = NodeChildProcess.execFileSync,
): string | undefined {