Skip to content

Commit 6c4d1de

Browse files
committed
fix(desktop): preserve launcher settings when replaying shell cache
1 parent 980f5af commit 6c4d1de

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,10 @@ describe("DesktopShellEnvironment", () => {
312312
environment: {
313313
PATH: "/cached/bin",
314314
__MISE_DIFF: "cached-mise",
315+
JAVA_HOME: "/cached/java",
316+
NODE_EXTRA_CA_CERTS: "/cached/ca.pem",
317+
SSL_CERT_FILE: "/cached/cert.pem",
318+
SSL_CERT_DIR: "/cached/certs",
315319
SSH_AUTH_SOCK: "/stale.sock",
316320
NODE_OPTIONS: "--bad",
317321
},
@@ -321,17 +325,36 @@ describe("DesktopShellEnvironment", () => {
321325
const env: NodeJS.ProcessEnv = {
322326
SHELL: "/bin/zsh",
323327
PATH: "/usr/bin",
328+
__MISE_DIFF: "launcher-mise",
329+
JAVA_HOME: "/launcher/java",
330+
NODE_EXTRA_CA_CERTS: "/launcher/ca.pem",
331+
SSL_CERT_FILE: "",
324332
SSH_AUTH_SOCK: "/current.sock",
325333
};
326334
const prepared = yield* runShellEnvironment({
327335
env,
328336
stateDir,
329337
platform: "darwin",
330338
handler: () => "",
339+
use: (service) =>
340+
Effect.gen(function* () {
341+
yield* service.installIntoProcess;
342+
const replay = yield* Stream.runHead(service.updates);
343+
assert.isTrue(Option.isSome(replay));
344+
if (Option.isSome(replay)) {
345+
assert.equal(replay.value.environment.JAVA_HOME, "/launcher/java");
346+
assert.equal(replay.value.environment.NODE_EXTRA_CA_CERTS, "/launcher/ca.pem");
347+
}
348+
return yield* service.awaitDiscovery;
349+
}),
331350
});
332351
assert.isFalse(prepared);
333352
assert.equal(env.PATH, "/cached/bin:/usr/bin");
334353
assert.equal(env.__MISE_DIFF, "cached-mise");
354+
assert.equal(env.JAVA_HOME, "/launcher/java");
355+
assert.equal(env.NODE_EXTRA_CA_CERTS, "/launcher/ca.pem");
356+
assert.equal(env.SSL_CERT_FILE, "");
357+
assert.equal(env.SSL_CERT_DIR, "/cached/certs");
335358
assert.equal(env.SSH_AUTH_SOCK, "/current.sock");
336359
assert.isUndefined(env.NODE_OPTIONS);
337360
assert.equal(yield* fs.readFileString(cachePath), contents);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,9 @@ export const make = Effect.gen(function* () {
626626
const cached = Object.fromEntries(
627627
CACHED_ENV_NAMES.flatMap((name) => {
628628
const value = cache.value.environment[name];
629+
// mise's metadata must describe the cached PATH entries restored alongside it.
630+
if (name !== "PATH" && name !== "__MISE_DIFF" && inherited[name] !== undefined)
631+
return [];
629632
return typeof value === "string" ? [[name, value]] : [];
630633
}),
631634
);

0 commit comments

Comments
 (0)