@devries-cameron20 / t3code Mirror · read-only / commits / ec1fa9abec
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(cli): t3 uninstall on Windows removes the downloaded runtime (#24874)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>

Victor Vogel committed Oct 31, 2026 at 03:39 UTC ec1fa9abec9a7393ac10a786180d2321fb2d1b7e
2 files changed +46 -9
apps/server/src/cli/uninstall.test.ts
+24 -1
@@ -5,7 +5,7 @@ import * as FileSystem from "effect/FileSystem";
5 import * as Path from "effect/Path";
6 import * as HostProcess from "@t3tools/shared/HostProcess";
7
8 -import { findOwnedLauncher } from "./uninstall.ts";
8 +import { findOwnedLauncher, spawnWindowsRemoval } from "./uninstall.ts";
9
10 it.layer(NodeServices.layer)("t3 uninstall launcher", (it) => {
11 it.effect("claims only a launcher that points into this home's runtime tree", () =>
@@ -35,3 +35,26 @@ it.layer(NodeServices.layer)("t3 uninstall launcher", (it) => {
35 }).pipe(Effect.scoped, Effect.provideService(HostProcess.Platform, "linux")),
36 );
37 });
38 +
39 +it.live.runIf(HostProcess.Platform.defaultValue() === "win32")(
40 + "t3 uninstall has cmd.exe remove the runtime directory, preserving spaces and literal environment-variable syntax",
41 + () =>
42 + Effect.gen(function* () {
43 + const fs = yield* FileSystem.FileSystem;
44 + const path = yield* Path.Path;
45 + const root = yield* fs.makeTempDirectoryScoped({ prefix: "t3-uninstall-" });
46 + const runtimeDir = path.join(root, "t3 home %COMSPEC% !COMSPEC! & data", "runtime");
47 + yield* fs.makeDirectory(path.join(runtimeDir, "versions", "1.0.0"), { recursive: true });
48 + yield* fs.writeFileString(path.join(runtimeDir, "versions", "1.0.0", "t3.exe"), "");
49 +
50 + const child = spawnWindowsRemoval(process.env.ComSpec ?? "cmd.exe", runtimeDir);
51 + yield* Effect.callback<void, Error>((resume) => {
52 + child.once("error", (error) => resume(Effect.fail(error)));
53 + child.once("exit", (code) =>
54 + resume(code === 0 ? Effect.void : Effect.die(`cmd.exe exited with ${code}`)),
55 + );
56 + });
57 +
58 + assert.isFalse(yield* fs.exists(runtimeDir));
59 + }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
60 +);
apps/server/src/cli/uninstall.ts
+22 -8
@@ -61,6 +61,27 @@ export const findOwnedLauncher = Effect.fn("cli.uninstall.find_launcher")(functi
61 return launcherOwnsVersionsDir(path, input.versionsDir, resolved) ? input.launchedAs : undefined;
62 });
63
64 +// cmd.exe needs verbatim quoting and a literal path, with delayed expansion disabled.
65 +export function spawnWindowsRemoval(comspec: string, dir: string) {
66 + return NodeChildProcess.spawn(
67 + comspec,
68 + [
69 + "/d",
70 + "/v:off",
71 + "/s",
72 + "/c",
73 + '"ping -n 3 127.0.0.1 >nul & rmdir /s /q "%T3_UNINSTALL_RUNTIME%""',
74 + ],
75 + {
76 + env: { ...process.env, T3_UNINSTALL_RUNTIME: dir },
77 + windowsVerbatimArguments: true,
78 + detached: true,
79 + stdio: "ignore",
80 + windowsHide: true,
81 + },
82 + );
83 +}
84 +
85 const planUninstall = Effect.fn("cli.uninstall.plan")(function* (input: {
86 readonly baseDir: string;
87 }) {
@@ -176,14 +197,7 @@ const runUninstall = Effect.fn("cli.uninstall.run")(function* (input: {
197 const runtimeDir = plan.runtimeDir;
198 const comspec = environment["ComSpec"] ?? environment["COMSPEC"] ?? "cmd.exe";
199 yield* Effect.try({
179 - try: () => {
180 - const child = NodeChildProcess.spawn(
181 - comspec,
182 - ["/d", "/c", `ping -n 3 127.0.0.1 >nul & rmdir /s /q "${runtimeDir}"`],
183 - { detached: true, stdio: "ignore", windowsHide: true },
184 - );
185 - child.unref();
186 - },
200 + try: () => spawnWindowsRemoval(comspec, runtimeDir).unref(),
201 catch: () =>
202 new CliUninstallError({
203 reason: `Could not schedule removal of ${runtimeDir}. Delete it yourself once this window is closed.`,