@devries-cameron20 / t3code Mirror · read-only / commits / 3d74f39a28
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 09:30 UTC

fix(server): put the updated runtime on the macOS service PATH (#23239)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Victor Vogel committed Oct 31, 2026 at 21:27 UTC 3d74f39a28cc47925878fa33d8b5f181aac0ded2
2 files changed +46 -13
apps/server/src/cloud/bootService.test.ts
+26 -2
@@ -170,6 +170,7 @@ const makeHarness = Effect.fn("test.make_boot_service_harness")(function* (
170 cliVersion = "1.2.3",
171 serviceBaseDir = baseDir,
172 insideService = false,
173 + hostExecPath = "/usr/bin/t3",
174 ) =>
175 Effect.gen(function* () {
176 const paths = pinnedRuntimePaths(path, serviceBaseDir, cliVersion, platform);
@@ -180,7 +181,7 @@ const makeHarness = Effect.fn("test.make_boot_service_harness")(function* (
181 baseDir: serviceBaseDir,
182 logsDir: path.join(serviceBaseDir, "userdata", "logs"),
183 cliVersion,
183 - host: { execPath: "/usr/bin/t3" },
184 + host: { execPath: hostExecPath },
185 });
186 }).pipe(
187 Effect.provideService(ProcessRunner.ProcessRunner, runner),
@@ -188,7 +189,7 @@ const makeHarness = Effect.fn("test.make_boot_service_harness")(function* (
189 Layer.mergeAll(
190 Layer.succeed(HostProcess.Platform, platform),
191 Layer.succeed(HostProcess.UserId, 501),
191 - Layer.succeed(HostProcess.ExecutablePath, "/usr/bin/t3"),
192 + Layer.succeed(HostProcess.ExecutablePath, hostExecPath),
193 Layer.succeed(
194 HttpClient.HttpClient,
195 HttpClient.make(() => Effect.die("no release download expected")),
@@ -829,6 +830,29 @@ it.layer(NodeServices.layer)("boot service install", (it) => {
830 }),
831 );
832
833 + // regression: #17532
834 + it.effect("puts the runtime an update installs on the launch agent PATH", () =>
835 + Effect.gen(function* () {
836 + const { makeService, fs, baseDir, runtime } = yield* makeHarness("darwin");
837 + const path = yield* Path.Path;
838 + const previous = runtime.versionDir;
839 + const installed = pinnedRuntimePaths(path, baseDir, "1.2.4", "darwin").versionDir;
840 + // The 1.2.3 CLI, or the 1.2.3 service's own PATH, installs 1.2.4.
841 + const updated = yield* makeService(
842 + `/usr/bin:${previous}:/bin`,
843 + "1.2.4",
844 + undefined,
845 + false,
846 + runtime.entryPath,
847 + );
848 + const plan = yield* updated.install();
849 +
850 + expect(yield* fs.readFileString(plan.unitPath)).toContain(
851 + ` <key>PATH</key>\n <string>/usr/bin:${installed}:/bin:/opt/homebrew/bin:/usr/local/bin:/usr/sbin:/sbin</string>`,
852 + );
853 + }),
854 + );
855 +
856 it.effect("drops PATH directories that cannot be represented in a launch agent plist", () =>
857 Effect.gen(function* () {
858 const { service, fs } = yield* makeHarness(
apps/server/src/cloud/bootService.ts
+20 -11
@@ -17,8 +17,10 @@ import { CLI_RELEASE_BASE_URL_ENV } from "@t3tools/shared/cliRelease";
17 import * as ProcessRunner from "../processRunner.ts";
18 import {
19 ensurePinnedRuntimeInstalled,
20 + launcherOwnsVersionsDir,
21 pinnedRuntimeCommand,
22 pinnedRuntimePaths,
23 + pinnedRuntimeVersionsDir,
24 PinnedRuntimeInstallError,
25 } from "./pinnedRuntime.ts";
26 import {
@@ -542,6 +544,8 @@ export const make = Effect.fn("cloud.boot_service.make")(function* (input: {
544 const path = yield* Path.Path;
545 const runner = yield* ProcessRunner.ProcessRunner;
546 const host = input.host ?? { execPath: hostExecPath };
547 + const runtimePaths = pinnedRuntimePaths(path, input.baseDir, input.cliVersion, platform);
548 + const versionsDir = pinnedRuntimeVersionsDir(path, input.baseDir);
549 const xmlSafeInstallerDirectories = installerPath.split(":").filter(
550 (directory) =>
551 directory.length > 0 &&
@@ -550,17 +554,23 @@ export const make = Effect.fn("cloud.boot_service.make")(function* (input: {
554 return code >= 0x20 || code === 0x09 || code === 0x0a || code === 0x0d;
555 }),
556 );
557 + // During an update, the running CLI and a PATH inherited from the service name the runtime
558 + // being replaced. The service and its agent shells should find the runtime it starts.
559 const environmentPath = Array.from(
554 - new Set([
555 - ...xmlSafeInstallerDirectories,
556 - path.dirname(host.execPath),
557 - "/opt/homebrew/bin",
558 - "/usr/local/bin",
559 - "/usr/bin",
560 - "/bin",
561 - "/usr/sbin",
562 - "/sbin",
563 - ]),
560 + new Set(
561 + [
562 + ...xmlSafeInstallerDirectories,
563 + path.dirname(host.execPath),
564 + "/opt/homebrew/bin",
565 + "/usr/local/bin",
566 + "/usr/bin",
567 + "/bin",
568 + "/usr/sbin",
569 + "/sbin",
570 + ].map((directory) =>
571 + launcherOwnsVersionsDir(path, versionsDir, directory) ? runtimePaths.versionDir : directory,
572 + ),
573 + ),
574 ).join(":");
575
576 const detectedManager = selectBootServiceManager({
@@ -574,7 +584,6 @@ export const make = Effect.fn("cloud.boot_service.make")(function* (input: {
584 const logPath = path.join(input.logsDir, BOOT_SERVICE_LOG_FILE);
585 const statePath = path.join(input.baseDir, "runtime", SERVICE_STATE_FILE);
586 const restartPendingPath = path.join(input.baseDir, "runtime", SERVICE_RESTART_PENDING_FILE);
577 - const runtimePaths = pinnedRuntimePaths(path, input.baseDir, input.cliVersion, platform);
587 const writeDurably = (filePath: string, contents: string) =>
588 Effect.scoped(
589 Effect.gen(function* () {