The best way to control Claude Code, Codex and more from any computer or phone
fix(cli): concurrent installs no longer nest a duplicate runtime (#38235)
Co-authored-by: Grok 4.7 <noreply@x.ai> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Wout Stiens committed
Nov 17, 2026 at 18:26 UTC
4d0e2f52d25a7cf663068b2d6f12c290d1a4f40f
2 files changed
+98
scripts/install.sh
+2
@@ -262,6 +262,8 @@ else
262
263
rm -rf "$target_dir"
264
mv "$staging" "$target_dir"
265
+ # When a concurrent install published first, mv moved this copy inside it; keep only theirs.
266
+ rm -rf "${target_dir}/${staging##*/}"
267
trap - EXIT
268
fi
269
scripts/install.test.ts
+96
@@ -536,3 +536,99 @@ describe.skipIf(HostProcess.Platform.defaultValue() !== "linux")("installer chec
536
},
537
);
538
});
539
+
540
+// regression: #38234
541
+describe.skipIf(HostProcess.Platform.defaultValue() !== "linux")("concurrent installers", () => {
542
+ it("publishes one runtime without nesting the other install's staging directory", async () => {
543
+ const root = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "t3-install-concurrent-"));
544
+ const version = "1.2.3";
545
+ const stem = `t3-${version}-linux-${HostProcess.Architecture.defaultValue()}`;
546
+ const archiveName = `${stem}.tar.gz`;
547
+ const target = NodePath.join(root, "home/runtime/versions", version);
548
+ const waiting = new Map<string, NodeHttp.ServerResponse>();
549
+ const server = NodeHttp.createServer();
550
+ try {
551
+ const tools = NodePath.join(root, "tools");
552
+ await NodeFSP.mkdir(tools);
553
+ await NodeFSP.mkdir(NodePath.join(root, stem));
554
+ await NodeFSP.writeFile(NodePath.join(root, stem, "t3"), "#!/bin/sh\necho 't3 v1.2.3'\n", {
555
+ mode: 0o755,
556
+ });
557
+ const archivePath = NodePath.join(root, archiveName);
558
+ NodeChildProcess.execFileSync("tar", ["-czf", archivePath, "-C", root, stem]);
559
+ const archive = await NodeFSP.readFile(archivePath);
560
+ const digest = NodeCrypto.createHash("sha256").update(archive).digest("hex");
561
+ server.on("request", (request, response) => {
562
+ if (request.url?.startsWith("/ready/")) {
563
+ waiting.set(request.url.slice(7), response);
564
+ if (waiting.size === 2) waiting.get("first")!.end("go");
565
+ } else if (request.url === "/published") {
566
+ waiting.get("second")!.end("go");
567
+ response.end("ok");
568
+ } else {
569
+ response.end(
570
+ request.url?.endsWith("/SHA256SUMS") ? `${digest} ${archiveName}\n` : archive,
571
+ );
572
+ }
573
+ });
574
+ await new Promise<void>((resolve) => server.listen(0, "127.0.0.1", resolve));
575
+ const address = server.address();
576
+ if (!address || typeof address === "string") throw new Error("Expected a TCP listener");
577
+ const origin = `http://127.0.0.1:${address.port}`;
578
+ const realMv = NodeChildProcess.execFileSync("sh", ["-c", "command -v mv"], {
579
+ encoding: "utf8",
580
+ }).trim();
581
+ // Hold publication until both installers have removed the destination, then let them rename in order.
582
+ const wrapper = NodePath.join(tools, "mv.mjs");
583
+ await NodeFSP.writeFile(
584
+ wrapper,
585
+ `
586
+import { execFileSync } from 'node:child_process';
587
+await fetch(process.env.T3_TEST_ORIGIN + '/ready/' + process.env.T3_TEST_INSTALLER);
588
+execFileSync(${JSON.stringify(realMv)}, process.argv.slice(2));
589
+if (process.env.T3_TEST_INSTALLER === 'first') await fetch(process.env.T3_TEST_ORIGIN + '/published');
590
+`,
591
+ );
592
+ await NodeFSP.writeFile(
593
+ NodePath.join(tools, "mv"),
594
+ `#!/bin/sh\nexec '${process.execPath}' '${wrapper}' "$@"\n`,
595
+ { mode: 0o755 },
596
+ );
597
+ const install = (id: string) =>
598
+ new Promise<{ code: number | null; output: string }>((resolve, reject) => {
599
+ const child = NodeChildProcess.spawn(
600
+ "sh",
601
+ [NodePath.join(import.meta.dirname, "install.sh")],
602
+ {
603
+ env: {
604
+ ...process.env,
605
+ PATH: `${tools}:${process.env.PATH}`,
606
+ T3CODE_VERSION: version,
607
+ T3CODE_HOME: NodePath.join(root, "home"),
608
+ T3CODE_INSTALL_BIN_DIR: NodePath.join(root, "bin", id),
609
+ T3CODE_RELEASE_BASE_URL: origin,
610
+ T3_TEST_ORIGIN: origin,
611
+ T3_TEST_INSTALLER: id,
612
+ },
613
+ stdio: ["ignore", "pipe", "pipe"],
614
+ },
615
+ );
616
+ let output = "";
617
+ child.stdout.on("data", (chunk: Buffer) => (output += chunk.toString()));
618
+ child.stderr.on("data", (chunk: Buffer) => (output += chunk.toString()));
619
+ child.on("error", reject);
620
+ child.on("close", (code) => resolve({ code, output }));
621
+ });
622
+ const results = await Promise.all([install("first"), install("second")]);
623
+ for (const result of results) expect(result.code, result.output).toBe(0);
624
+ expect(
625
+ (await NodeFSP.readdir(target)).filter((name) => name.startsWith(".staging-")),
626
+ "concurrent installs must not leave a nested runtime",
627
+ ).toEqual([]);
628
+ } finally {
629
+ server.closeAllConnections();
630
+ await new Promise<void>((resolve) => server.close(() => resolve()));
631
+ await NodeFSP.rm(root, { recursive: true, force: true });
632
+ }
633
+ });
634
+});