The best way to control Claude Code, Codex and more from any computer or phone
fix(server): t3 uninstall names another home's service it leaves installed (#35684)
Julius Marminge committed
Nov 12, 2026 at 15:45 UTC
6dfb1a8a1868b9d90a6f21e983cfea370c07ba0b
2 files changed
+83
-4
apps/server/src/cli/uninstall.test.ts
+67
-1
@@ -1,12 +1,78 @@
1
import * as NodeServices from "@effect/platform-node/NodeServices";
2
import { assert, it } from "@effect/vitest";
3
import * as Config from "effect/Config";
4
+import * as ConfigProvider from "effect/ConfigProvider";
5
import * as Effect from "effect/Effect";
6
import * as FileSystem from "effect/FileSystem";
7
+import * as Layer from "effect/Layer";
8
import * as Path from "effect/Path";
9
+import * as TestConsole from "effect/testing/TestConsole";
10
+import { Command } from "effect/cli";
11
import * as HostProcess from "@t3tools/shared/HostProcess";
12
+import * as NetService from "@t3tools/shared/Net";
13
+import { afterEach, vi } from "vite-plus/test";
14
9
-import { findOwnedLauncher, findRecordedLaunchers, spawnWindowsRemoval } from "./uninstall.ts";
15
+import packageJson from "../../package.json" with { type: "json" };
16
+import * as BootService from "../cloud/bootService.ts";
17
+import {
18
+ findOwnedLauncher,
19
+ findRecordedLaunchers,
20
+ spawnWindowsRemoval,
21
+ uninstallCommand,
22
+} from "./uninstall.ts";
23
+
24
+afterEach(() => vi.restoreAllMocks());
25
+
26
+it.layer(Layer.mergeAll(NodeServices.layer, NetService.layer))("t3 uninstall command", (it) => {
27
+ it.effect("names another home's service it leaves installed", () =>
28
+ Effect.gen(function* () {
29
+ const fs = yield* FileSystem.FileSystem;
30
+ const baseDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-uninstall-cli-test-" });
31
+ const uninstalls: Array<true> = [];
32
+ vi.spyOn(BootService, "layer").mockReturnValue(
33
+ Layer.succeed(
34
+ BootService.BootService,
35
+ BootService.BootService.of({
36
+ status: Effect.succeed({
37
+ supported: true,
38
+ installed: true,
39
+ current: true,
40
+ installedBaseDir: "/home/me/.t3",
41
+ unitPath: "/home/me/.config/systemd/user/t3code.service",
42
+ logPath: "/home/me/.t3/userdata/logs/boot-service.log",
43
+ }),
44
+ withStopped: (operation) => operation,
45
+ restart: Effect.die("unexpected restart"),
46
+ install: () => Effect.die("unexpected install"),
47
+ uninstall: Effect.sync(() => {
48
+ uninstalls.push(true);
49
+ return true;
50
+ }),
51
+ }),
52
+ ),
53
+ );
54
+
55
+ const output = yield* Command.runWith(uninstallCommand, { version: packageJson.version })([
56
+ "--base-dir",
57
+ baseDir,
58
+ "--yes",
59
+ ]).pipe(
60
+ Effect.andThen(TestConsole.logLines),
61
+ Effect.map((lines) => lines.join("\n")),
62
+ Effect.provideService(HostProcess.Environment, {}),
63
+ Effect.provideService(HostProcess.IsExecutable, false),
64
+ Effect.provide(
65
+ Layer.mergeAll(
66
+ ConfigProvider.layer(ConfigProvider.fromEnv({ env: {} })),
67
+ Layer.fresh(TestConsole.layer),
68
+ ),
69
+ ),
70
+ );
71
+ assert.deepStrictEqual(uninstalls, []);
72
+ assert.include(output, "--base-dir '/home/me/.t3'");
73
+ }),
74
+ );
75
+});
76
77
it.layer(NodeServices.layer)("t3 uninstall launcher", (it) => {
78
it.effect("claims only a launcher that points into this home's runtime tree", () =>
apps/server/src/cli/uninstall.ts
+16
-3
@@ -33,6 +33,7 @@ export class CliUninstallError extends Schema.TaggedError<CliUninstallError>()(
33
34
export interface UninstallPlan {
35
readonly service: boolean;
36
+ readonly otherHomeService: string | undefined;
37
readonly versionsDir: string;
38
readonly launchers: ReadonlyArray<string>;
39
readonly runtimeDir: string | undefined;
@@ -147,15 +148,18 @@ const planUninstall = Effect.fn("cli.uninstall.plan")(function* (input: {
148
const path = yield* Path.Path;
149
const service = yield* BootService.BootService;
150
const status = yield* service.status;
151
+ const installedBaseDir =
152
+ status.supported && status.installed ? status.installedBaseDir : undefined;
153
const servesThisHome =
151
- status.installedBaseDir !== undefined &&
152
- path.resolve(status.installedBaseDir) === path.resolve(input.baseDir);
154
+ installedBaseDir !== undefined &&
155
+ path.resolve(installedBaseDir) === path.resolve(input.baseDir);
156
const versionsDir = pinnedRuntimeVersionsDir(path, input.baseDir);
157
const runtimeDir = path.dirname(versionsDir);
158
const launchedAs = (yield* HostProcess.IsExecutable) ? yield* resolveLauncherPath : undefined;
159
const launchedFrom = yield* findOwnedLauncher({ launchedAs, versionsDir });
160
const plan: UninstallPlan = {
158
- service: status.supported && status.installed && servesThisHome,
161
+ service: servesThisHome,
162
+ otherHomeService: servesThisHome ? undefined : installedBaseDir,
163
versionsDir,
164
launchers: [
165
...new Set([
@@ -195,6 +199,13 @@ export const uninstallCommand = Command.make("uninstall", {
199
),
200
);
201
202
+const logOtherHomeService = (plan: UninstallPlan) =>
203
+ plan.otherHomeService === undefined
204
+ ? Effect.void
205
+ : Console.log(
206
+ `The T3 Code service serves ${plan.otherHomeService}, so it was not removed. Pass \`${BootService.formatBootServiceBaseDirOption(plan.otherHomeService)}\` to remove it.`,
207
+ );
208
+
209
const runUninstall = Effect.fn("cli.uninstall.run")(function* (input: {
210
readonly baseDir: string;
211
readonly assumeYes: boolean;
@@ -212,6 +223,7 @@ const runUninstall = Effect.fn("cli.uninstall.run")(function* (input: {
223
" This t3 runs from a Node script, so it was installed by npm or built from source. Remove it the same way (`npm uninstall -g t3`, or delete the checkout).",
224
);
225
}
226
+ yield* logOtherHomeService(plan);
227
return;
228
}
229
@@ -286,4 +298,5 @@ const runUninstall = Effect.fn("cli.uninstall.run")(function* (input: {
298
}
299
yield* Console.log("");
300
yield* Console.log("t3 is uninstalled. Thanks for trying T3 Code.");
301
+ yield* logOtherHomeService(plan);
302
});