Skip to content

Commit cc0b565

Browse files
committed
fix(desktop): a timed-out login-shell probe no longer skips the server's PATH repair
The POSIX branch reported the shell environment as prepared even when no login shell answered, so the bundled server skipped its own probe and ran with launchd's PATH for the whole session. Refs #10534.
1 parent 1451e7c commit cc0b565

3 files changed

Lines changed: 26 additions & 6 deletions

File tree

‎apps/desktop/src/backend/DesktopBackendConfiguration.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ const resolvePrimaryStartConfig = Effect.fn("desktop.backendConfiguration.resolv
519519
host: backendExposure.bindHost,
520520
desktopBootstrapToken: input.bootstrapToken,
521521
desktopBootstrapSecret: input.bootstrapSecret,
522-
// Failed Windows probes leave server hydration enabled for another attempt.
522+
// Failed probes leave server hydration enabled for another attempt.
523523
shellEnvironmentPrepared: input.shellEnvironmentPrepared,
524524
tailscaleServeEnabled: backendExposure.tailscaleServeEnabled,
525525
tailscaleServePort: backendExposure.tailscaleServePort,

‎apps/desktop/src/shell/DesktopShellEnvironment.test.ts‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ describe("DesktopShellEnvironment", () => {
199199
};
200200
const commands: ChildProcess.Command[] = [];
201201

202-
yield* runShellEnvironment({
202+
const prepared = yield* runShellEnvironment({
203203
env,
204204
platform: "darwin",
205205
handler: (command) => {
@@ -217,6 +217,7 @@ describe("DesktopShellEnvironment", () => {
217217
assert.equal(env.PATH, "/opt/homebrew/bin:/usr/bin:/Users/test/.local/bin");
218218
assert.equal(env.SSH_AUTH_SOCK, "/tmp/secretive.sock");
219219
assert.equal(env.HOMEBREW_PREFIX, "/opt/homebrew");
220+
assert.isTrue(prepared);
220221
}),
221222
);
222223

@@ -424,7 +425,7 @@ describe("DesktopShellEnvironment", () => {
424425
};
425426
const commands: string[] = [];
426427

427-
yield* runShellEnvironment({
428+
const prepared = yield* runShellEnvironment({
428429
env,
429430
platform: "darwin",
430431
handler: (command) => {
@@ -436,6 +437,20 @@ describe("DesktopShellEnvironment", () => {
436437

437438
assert.deepEqual(commands, ["/opt/homebrew/bin/nu", "/bin/zsh", "/bin/launchctl"]);
438439
assert.equal(env.PATH, "/opt/homebrew/bin:/usr/bin");
440+
assert.isFalse(prepared);
441+
}),
442+
);
443+
444+
it.effect("leaves macOS preparation incomplete when no login shell returns a PATH", () =>
445+
Effect.gen(function* () {
446+
// A probe that times out yields the same empty output as this reply.
447+
const prepared = yield* runShellEnvironment({
448+
env: { SHELL: "/bin/zsh", PATH: "/usr/bin:/bin:/usr/sbin:/sbin" },
449+
platform: "darwin",
450+
handler: () => "",
451+
});
452+
453+
assert.isFalse(prepared);
439454
}),
440455
);
441456

‎apps/desktop/src/shell/DesktopShellEnvironment.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ const installPosixEnvironment = Effect.fn("desktop.shellEnvironment.installPosix
403403
function* (
404404
config: ShellEnvironmentConfig,
405405
): Effect.fn.Return<
406-
void,
406+
boolean,
407407
never,
408408
ChildProcessSpawner.ChildProcessSpawner | FileSystem.FileSystem
409409
> {
@@ -422,8 +422,9 @@ const installPosixEnvironment = Effect.fn("desktop.shellEnvironment.installPosix
422422
config.platform === "darwin" && !shellEnvironment.PATH
423423
? yield* readLaunchctlPath
424424
: Option.none<string>();
425+
const shellPath = trimNonEmpty(shellEnvironment.PATH);
425426
const mergedPath = mergePaths(config.platform, [
426-
trimNonEmpty(shellEnvironment.PATH).pipe(Option.orElse(() => launchctlPath)),
427+
shellPath.pipe(Option.orElse(() => launchctlPath)),
427428
readEnvPath(config.env),
428429
]);
429430

@@ -510,6 +511,10 @@ const installPosixEnvironment = Effect.fn("desktop.shellEnvironment.installPosix
510511
}
511512
}
512513
}
514+
515+
// Only a login-shell PATH counts; a launchctl-only PATH still leaves
516+
// server hydration enabled.
517+
return Option.isSome(shellPath);
513518
},
514519
);
515520

@@ -524,7 +529,7 @@ const installShellEnvironment = (
524529
return installWindowsEnvironment(config);
525530
}
526531
if (config.platform === "darwin" || config.platform === "linux") {
527-
return installPosixEnvironment(config).pipe(Effect.as(true));
532+
return installPosixEnvironment(config);
528533
}
529534
return Effect.succeed(false);
530535
};

0 commit comments

Comments
 (0)