@devries-cameron20 / t3code-1 / commits / cf930195b4
Fork 0

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

fix(cli): keep --base-dir in the sudo command browser setup prints (#23646)

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

Victor Vogel committed Oct 30, 2026 at 15:56 UTC cf930195b4d6bf47156df2f0fbefe2e6d0c05627
3 files changed +29 -5
apps/server/src/cli/browser.ts
+8 -3
@@ -114,16 +114,21 @@ const browserSetupCommand = Command.make("setup", { baseDir: baseDirFlag }).pipe
114 }
115 const fs = yield* FileSystem.FileSystem;
116 const isRoot = (yield* HostProcess.UserId) === 0;
117 - const setupCommand = yield* resolveRootCliCommand(PreviewBrowserHost.SETUP_SUBCOMMAND);
118 - // Root, unless sudo came from another user, is likely the server's own account.
117 const env = yield* HostProcess.Environment;
118 + const baseDirPath = yield* setupBaseDir(baseDir);
119 + // sudo resets the environment, so a chosen home has to be on the command line.
120 + const setupCommand = yield* resolveRootCliCommand(
121 + PreviewBrowserHost.SETUP_SUBCOMMAND,
122 + Option.isSome(baseDir) || env.T3CODE_HOME !== undefined ? ["--base-dir", baseDirPath] : [],
123 + );
124 + // Root, unless sudo came from another user, is likely the server's own account.
125 const rootWarning =
126 isRoot && (env.SUDO_USER ?? "root") === "root" && !PreviewBrowserHost.sandboxDisabled(env)
127 ? new PreviewBrowserHost.PreviewBrowserRootError().message
128 : undefined;
129
130 const needsProfile = yield* PreviewBrowserHost.sandboxBlocked;
126 - const browser = yield* installedBrowser(yield* setupBaseDir(baseDir));
131 + const browser = yield* installedBrowser(baseDirPath);
132 const missing = Option.isSome(browser)
133 ? yield* PreviewBrowserHost.missingLibraries(browser.value)
134 : [];
apps/server/src/cli/invocation.test.ts
+19 -1
@@ -19,8 +19,9 @@ it.layer(NodeServices.layer)("root CLI commands", (it) => {
19 readonly path?: string;
20 readonly env?: Record<string, string>;
21 readonly executable?: boolean;
22 + readonly args?: ReadonlyArray<string>;
23 }) =>
23 - resolveRootCliCommand("browser setup").pipe(
24 + resolveRootCliCommand("browser setup", input.args).pipe(
25 Effect.provideService(HostProcess.ExecutablePath, input.node),
26 Effect.provideService(HostProcess.Arguments, [input.node, input.entry]),
27 Effect.provideService(HostProcess.IsExecutable, input.executable ?? false),
@@ -55,6 +56,23 @@ it.layer(NodeServices.layer)("root CLI commands", (it) => {
56 }).pipe(Effect.scoped),
57 );
58
59 + it.effect("keeps the arguments, so root runs setup on the same T3 home", () =>
60 + Effect.gen(function* () {
61 + const args = ["--base-dir", "/srv/t3 home"];
62 + expect(
63 + yield* rootCommand({
64 + node: "/home/theo/.local/node/bin/node",
65 + entry: "/home/theo/.local/lib/node_modules/t3/dist/bin.mjs",
66 + path: yield* pathWithT3,
67 + args,
68 + }),
69 + ).toBe(`sudo env "PATH=$PATH" t3 browser setup --base-dir '/srv/t3 home'`);
70 + expect(
71 + yield* rootCommand({ node: "/opt/t3/t3", entry: "/opt/t3/t3", executable: true, args }),
72 + ).toBe("sudo /opt/t3/t3 browser setup --base-dir '/srv/t3 home'");
73 + }).pipe(Effect.scoped),
74 + );
75 +
76 it.effect("names this install's launcher when t3 is not on PATH", () =>
77 Effect.gen(function* () {
78 const fs = yield* FileSystem.FileSystem;
apps/server/src/cli/invocation.ts
+2 -1
@@ -181,8 +181,9 @@ export const resolveHostCliCommand = Effect.fn("invocation.resolveHostCliCommand
181 */
182 export const resolveRootCliCommand = Effect.fn("invocation.resolveRootCliCommand")(function* (
183 subcommand: string,
184 + args: ReadonlyArray<string> = [],
185 ) {
185 - const { command, launcher } = yield* resolveHostCliCommand(subcommand);
186 + const { command, launcher } = yield* resolveHostCliCommand(subcommand, args);
187 if (launcher) return `sudo ${command}`;
188 const executablePath = yield* HostProcess.ExecutablePath;
189 const systemNode = ROOT_PATH_DIRECTORIES.some((directory) =>