Skip to content
TypeScript

fix(desktop): a timed-out login-shell probe no longer skips the server's PATH repair (#21771)

tiliakoos5e35f6ea1cec
diff --git a/apps/desktop/src/shell/DesktopShellEnvironment.test.ts b/apps/desktop/src/shell/DesktopShellEnvironment.test.ts
index 9d12ed5a07f..48048230690 100644
--- a/apps/desktop/src/shell/DesktopShellEnvironment.test.ts
+++ b/apps/desktop/src/shell/DesktopShellEnvironment.test.ts
@@ -149,7 +149,7 @@ describe("DesktopShellEnvironment", () => {
};
const commands: ChildProcess.Command[] = [];
- yield* runShellEnvironment({
+ const prepared = yield* runShellEnvironment({
env,
platform: "darwin",
handler: (command) => {
@@ -167,6 +167,7 @@ describe("DesktopShellEnvironment", () => {
assert.equal(env.PATH, "/opt/homebrew/bin:/usr/bin:/Users/test/.local/bin");
assert.equal(env.SSH_AUTH_SOCK, "/tmp/secretive.sock");
assert.equal(env.HOMEBREW_PREFIX, "/opt/homebrew");
+ assert.isTrue(prepared);
}),
);
@@ -267,7 +268,7 @@ describe("DesktopShellEnvironment", () => {
};
const commands: string[] = [];
- yield* runShellEnvironment({
+ const prepared = yield* runShellEnvironment({
env,
platform: "darwin",
handler: (command) => {
@@ -279,6 +280,19 @@ describe("DesktopShellEnvironment", () => {
assert.deepEqual(commands, ["/opt/homebrew/bin/nu", "/bin/zsh", "/bin/launchctl"]);
assert.equal(env.PATH, "/opt/homebrew/bin:/usr/bin");
+ assert.isFalse(prepared);
+ }),
+ );
+
+ it.effect("leaves macOS preparation incomplete when no login shell returns a PATH", () =>
+ Effect.gen(function* () {
+ const prepared = yield* runShellEnvironment({
+ env: { SHELL: "/bin/zsh", PATH: "/usr/bin:/bin:/usr/sbin:/sbin" },
+ platform: "darwin",
+ handler: () => "",
+ });
+
+ assert.isFalse(prepared);
}),
);
diff --git a/apps/desktop/src/shell/DesktopShellEnvironment.ts b/apps/desktop/src/shell/DesktopShellEnvironment.ts
index 25c37ecefc0..6e0fdbd3805 100644
--- a/apps/desktop/src/shell/DesktopShellEnvironment.ts
+++ b/apps/desktop/src/shell/DesktopShellEnvironment.ts
@@ -392,7 +392,7 @@ const installPosixEnvironment = Effect.fn("desktop.shellEnvironment.installPosix
function* (
config: ShellEnvironmentConfig,
): Effect.fn.Return<
- void,
+ boolean,
never,
ChildProcessSpawner.ChildProcessSpawner | FileSystem.FileSystem
> {
@@ -491,6 +491,8 @@ const installPosixEnvironment = Effect.fn("desktop.shellEnvironment.installPosix
}
}
}
+
+ return Option.isSome(trimNonEmpty(shellEnvironment.PATH));
},
);
@@ -505,7 +507,7 @@ const installShellEnvironment = (
return installWindowsEnvironment(config);
}
if (config.platform === "darwin" || config.platform === "linux") {
- return installPosixEnvironment(config).pipe(Effect.as(true));
+ return installPosixEnvironment(config);
}
return Effect.succeed(false);
};