Skip to content

Commit 712d57c

Browse files
committed
fix(server): keep repointing launchers after one rewrite fails
- Log a failed launcher rewrite and move on to the next candidate - Cover a read-only install bin dir alongside a PATH launcher
1 parent 2c35d88 commit 712d57c

2 files changed

Lines changed: 44 additions & 1 deletion

File tree

‎apps/server/src/cli/update.test.ts‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,40 @@ it.layer(NodeServices.layer)("t3 update launcher", (it) => {
140140
assert.equal(yield* fs.readLink(pinned), exe("1.5.0"));
141141
}).pipe(Effect.scoped, Effect.provideService(HostProcessPlatform, "linux")),
142142
);
143+
144+
it.effect("still moves the PATH launcher when the install bin one cannot be rewritten", () =>
145+
Effect.gen(function* () {
146+
const fs = yield* FileSystem.FileSystem;
147+
const path = yield* Path.Path;
148+
const root = yield* fs.makeTempDirectoryScoped({ prefix: "t3-update-" });
149+
const baseDir = path.join(root, ".t3");
150+
const exe = (version: string) => path.join(baseDir, "runtime/versions", version, "t3");
151+
const installed = path.join(root, ".local/bin/t3");
152+
const onPath = path.join(root, "bin/t3");
153+
for (const file of [exe("1.0.0"), exe("2.0.0")]) {
154+
yield* fs.makeDirectory(path.dirname(file), { recursive: true });
155+
yield* fs.writeFileString(file, "");
156+
}
157+
for (const link of [installed, onPath]) {
158+
yield* fs.makeDirectory(path.dirname(link), { recursive: true });
159+
yield* fs.symlink(exe("1.0.0"), link);
160+
}
161+
yield* fs.chmod(path.dirname(installed), 0o555);
162+
163+
yield* repointLauncherAfterSelfUpdate({
164+
baseDir,
165+
fromVersion: "1.0.0",
166+
targetVersion: "2.0.0",
167+
}).pipe(
168+
Effect.provideService(HostProcessEnvironment, {
169+
HOME: root,
170+
PATH: path.dirname(onPath),
171+
}),
172+
Effect.ensuring(fs.chmod(path.dirname(installed), 0o755).pipe(Effect.orDie)),
173+
);
174+
175+
assert.equal(yield* fs.readLink(installed), exe("1.0.0"));
176+
assert.equal(yield* fs.readLink(onPath), exe("2.0.0"));
177+
}).pipe(Effect.scoped, Effect.provideService(HostProcessPlatform, "linux")),
178+
);
143179
});

‎apps/server/src/cli/update.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,14 @@ export const repointLauncherAfterSelfUpdate = Effect.fn(
225225
// Ownership scoped to the previous version: a `t3` pinned elsewhere stays put.
226226
versionsDir: from.versionDir,
227227
targetEntryPath: target.entryPath,
228-
});
228+
}).pipe(
229+
Effect.catch((cause) =>
230+
Effect.logWarning("Could not move the t3 command to the updated version", {
231+
launchedAs,
232+
cause,
233+
}),
234+
),
235+
);
229236
}
230237
});
231238

0 commit comments

Comments
 (0)