Skip to content

Commit 99da2d3

Browse files
fix(server): a PATH directory linked to a version still pins it
Only a candidate written as versions/<version>/t3 that is not itself a link is a runtime's own entry; a linked PATH directory reaches the same file under another name. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 51d6213 commit 99da2d3

2 files changed

Lines changed: 23 additions & 11 deletions

File tree

‎apps/server/src/cloud/pinnedRuntime.test.ts‎

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -479,27 +479,37 @@ it.layer(NodeServices.layer)("prunePinnedRuntimes", (it) => {
479479
}),
480480
);
481481

482-
it.effect("keeps a runtime a launcher inside the versions directory names", () =>
482+
it.effect.each([
483+
{ name: "a launcher inside the versions directory", via: "bin" as const },
484+
{ name: "a PATH directory linked to its version directory", via: "linked dir" as const },
485+
])("keeps a runtime $name names", ({ via }) =>
483486
Effect.gen(function* () {
484487
const fs = yield* FileSystem.FileSystem;
485488
const path = yield* Path.Path;
486489
const { baseDir, versionsDir } = yield* setup(["1.0.0", "1.1.0"]);
487-
// The installer accepts any bin directory, including one under the versions directory.
488-
const binDir = path.join(versionsDir, "bin");
489-
yield* fs.makeDirectory(binDir);
490-
yield* fs.symlink(path.join(versionsDir, "1.0.0", "t3"), path.join(binDir, "t3"));
491-
yield* fs.writeFileString(
492-
path.join(baseDir, "runtime", "launchers"),
493-
`${path.join(binDir, "t3")}\n`,
494-
);
490+
let pathDirs = "/usr/bin:/bin";
491+
if (via === "bin") {
492+
// The installer accepts any bin directory, including one under the versions directory.
493+
const binDir = path.join(versionsDir, "bin");
494+
yield* fs.makeDirectory(binDir);
495+
yield* fs.symlink(path.join(versionsDir, "1.0.0", "t3"), path.join(binDir, "t3"));
496+
yield* fs.writeFileString(
497+
path.join(baseDir, "runtime", "launchers"),
498+
`${path.join(binDir, "t3")}\n`,
499+
);
500+
} else {
501+
const linkedDir = path.join(baseDir, "current");
502+
yield* fs.symlink(path.join(versionsDir, "1.0.0"), linkedDir);
503+
pathDirs = `${linkedDir}:${pathDirs}`;
504+
}
495505

496506
const removed = yield* prunePinnedRuntimes({ baseDir, keep: ["2.0.0"] }).pipe(
497507
Effect.provideService(
498508
ProcessRunner.ProcessRunner,
499509
lsofRunner("p1\nftxt\nn/sbin/launchd\n"),
500510
),
501511
Effect.provideService(HostProcess.Platform, "darwin"),
502-
Effect.provideService(HostProcess.Environment, { PATH: "/usr/bin:/bin" }),
512+
Effect.provideService(HostProcess.Environment, { PATH: pathDirs }),
503513
);
504514
assert.deepEqual(removed, ["1.1.0"]);
505515
}),

‎apps/server/src/cloud/pinnedRuntime.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,9 @@ const shellLauncherTargets = Effect.fn("cloud.pinned_runtime.shell_launcher_targ
429429
yield* fs.realPath(launcher).pipe(Effect.orElseSucceed(() => undefined));
430430
if (target === undefined) continue;
431431
// A runtime's own entry, on the macOS service PATH or recorded by an earlier prune, is no launcher.
432-
if (platform !== "win32" && inVersionsDir(target)) {
432+
// It is named as `versions/<version>/t3` and is not itself a link.
433+
const parent = path.dirname(path.dirname(path.resolve(launcher)));
434+
if (platform !== "win32" && (parent === versionsDir || parent === realVersionsDir)) {
433435
const unlinked = yield* fs.realPath(path.dirname(launcher)).pipe(
434436
Effect.map((directory) => path.join(directory, path.basename(launcher))),
435437
Effect.orElseSucceed(() => undefined),

0 commit comments

Comments
 (0)