The best way to control Claude Code, Codex and more from any computer or phone
fix(cli): make relative install homes produce working commands (#29241)
Lakshmi Tanmay committed
Nov 3, 2026 at 07:09 UTC
87e13d3fe177026f33defc601124a4fbb211a19d
2 files changed
+56
scripts/install.sh
+8
@@ -20,6 +20,14 @@ set -eu
20
repo="pingdotgg/t3code"
21
base_url="${T3CODE_RELEASE_BASE_URL:-https://github.com/${repo}/releases/download}"
22
t3_home="${T3CODE_HOME:-$HOME/.t3}"
23
+case "$t3_home" in
24
+ /*) ;;
25
+ *)
26
+ # Preserve cwd's trailing newlines; trim only pwd's newline and the sentinel.
27
+ t3_cwd="$(pwd -P && printf .)"
28
+ t3_home="${t3_cwd%??}/$t3_home"
29
+ ;;
30
+esac
31
bin_dir="${T3CODE_INSTALL_BIN_DIR:-$HOME/.local/bin}"
32
33
fail() {
scripts/install.test.ts
+48
@@ -12,6 +12,54 @@ const nightlies = Array.from({ length: 100 }, (_, index) => ({
12
tag_name: `v1.2.4-nightly.20261020.${200 - index}`,
13
}));
14
15
+describe.skipIf(HostProcess.Platform.defaultValue() !== "linux")("installer home", () => {
16
+ it("installs a relative home from a directory ending in a newline", async () => {
17
+ const temporaryRoot = await NodeFSP.realpath(
18
+ await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "t3-install-home-")),
19
+ );
20
+ const root = NodePath.join(temporaryRoot, "cwd\n");
21
+ const homeName = "-custom home\\home\n";
22
+ const home = NodePath.join(root, homeName);
23
+ const version = "1.2.3";
24
+ const target = NodePath.join(home, "runtime/versions", version);
25
+ const launcher = NodePath.join(root, "bin/t3");
26
+ try {
27
+ await NodeFSP.mkdir(target, { recursive: true });
28
+ await NodeFSP.writeFile(NodePath.join(target, ".install-complete"), `${version}\n`);
29
+ await NodeFSP.writeFile(NodePath.join(target, "t3"), "#!/bin/sh\necho 't3 v1.2.3'\n", {
30
+ mode: 0o755,
31
+ });
32
+ const { status, stdout, stderr } = NodeChildProcess.spawnSync(
33
+ "sh",
34
+ [NodePath.resolve(import.meta.dirname, "install.sh")],
35
+ {
36
+ cwd: root,
37
+ env: {
38
+ ...process.env,
39
+ HOME: root,
40
+ T3CODE_HOME: homeName,
41
+ T3CODE_VERSION: version,
42
+ T3CODE_INSTALL_BIN_DIR: NodePath.dirname(launcher),
43
+ T3CODE_RELEASE_BASE_URL: "http://127.0.0.1:1",
44
+ },
45
+ encoding: "utf8",
46
+ },
47
+ );
48
+ expect(status, stdout + stderr).toBe(0);
49
+ expect(stderr).toContain(`Installed T3 Code ${version}`);
50
+ expect(await NodeFSP.readlink(launcher)).toBe(NodePath.join(target, "t3"));
51
+ expect(
52
+ NodeChildProcess.execFileSync(launcher, ["--version"], {
53
+ cwd: NodeOS.tmpdir(),
54
+ encoding: "utf8",
55
+ }).trim(),
56
+ ).toBe("t3 v1.2.3");
57
+ } finally {
58
+ await NodeFSP.rm(temporaryRoot, { recursive: true, force: true });
59
+ }
60
+ });
61
+});
62
+
63
// regression: #22490
64
describe.skipIf(HostProcess.Platform.defaultValue() !== "linux")("installer channel lookup", () => {
65
it.each([