Skip to content

[Bug]: Windows uninstall reports success when its cleanup shell cannot start #38042

Closed

Description

@StiensWout

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. On Windows, open PowerShell.
  2. Install the standalone T3 Code command by running: irm https://t3.codes/install.ps1 | iex
  3. In that same window, point the command interpreter at a program that is not there: $env:ComSpec = "$env:USERPROFILE\missing-cmd.exe"
  4. Run the installed program itself, not the t3 command: & (Get-ChildItem "$env:USERPROFILE.t3\runtime\versions*\t3.exe" | Select-Object -First 1).FullName uninstall --yes
  5. Read what the command prints, then open the folder %USERPROFILE%.t3\runtime.

Expected behavior

The command reports that cleanup could not be scheduled, tells the person to delete the remaining runtime folder after the window closes, and exits with an error. It does not say that removal was scheduled or that uninstall succeeded.

Actual behavior

The command prints that the runtime folder will be removed once it exits, then prints that t3 is uninstalled. The runtime folder is still there. The window can also show an error that the cleanup program failed to start, after the success lines.

Impact

Minor bug or occasional failure. Windows users with an unavailable command interpreter meet this failure on every uninstall attempt, after earlier removal steps may already have completed.

Version or commit

main at 9bc3fda0ac. The cause is at apps/server/src/cli/uninstall.ts:281.

Environment

Linux x64, the repository's own tests.

Logs or stack traces

an unavailable cleanup shell must fail uninstall
Automated repro

Fails in 2 of 2 runs on main: apply the patch with git apply, then run the command.

diff --git a/apps/server/src/cli/uninstall.test.ts b/apps/server/src/cli/uninstall.test.ts
index b93ad204fe..c22760da53 100644
--- a/apps/server/src/cli/uninstall.test.ts
+++ b/apps/server/src/cli/uninstall.test.ts
@@ -1,3 +1,5 @@
+// @effect-diagnostics nodeBuiltinImport:off - The test observes a real cleanup-shell spawn failure.
+import * as NodeChildProcess from "node:child_process";
 import * as NodeServices from "@effect/platform-node/NodeServices";
 import { assert, it } from "@effect/vitest";
 import * as Config from "effect/Config";
@@ -10,7 +12,7 @@ import * as TestConsole from "effect/testing/TestConsole";
 import { Command } from "effect/cli";
 import * as HostProcess from "@t3tools/shared/HostProcess";
 import * as NetService from "@t3tools/shared/Net";
-import { afterEach, vi } from "vite-plus/test";
+import { afterEach, expect, vi } from "vite-plus/test";
 
 import packageJson from "../../package.json" with { type: "json" };
 import * as BootService from "../cloud/bootService.ts";
@@ -22,8 +24,70 @@ import {
   uninstallCommand,
 } from "./uninstall.ts";
 
+vi.mock("node:child_process", { spy: true });
+
 afterEach(() => vi.restoreAllMocks());
 
+it.live("reports failure when the Windows cleanup shell cannot start", () =>
+  Effect.gen(function* () {
+    const fs = yield* FileSystem.FileSystem;
+    const path = yield* Path.Path;
+    const baseDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-uninstall-shell-" });
+    const runtimeDir = path.join(baseDir, "runtime");
+    yield* fs.makeDirectory(runtimeDir);
+    vi.spyOn(BootService, "layer").mockReturnValue(
+      Layer.succeed(
+        BootService.BootService,
+        BootService.BootService.of({
+          status: Effect.succeed({
+            supported: false,
+            installed: false,
+            current: false,
+            unitPath: "",
+            logPath: "",
+          }),
+          withStopped: (operation) => operation,
+          restart: Effect.die("unexpected restart"),
+          install: () => Effect.die("unexpected install"),
+          uninstall: Effect.die("unexpected uninstall"),
+        }),
+      ),
+    );
+    const actual = yield* Effect.promise(() =>
+      vi.importActual<typeof import("node:child_process")>("node:child_process"),
+    );
+    const spawn = actual.spawn;
+    const failedSpawn = new Promise<Error>((resolve) => {
+      vi.spyOn(NodeChildProcess, "spawn").mockImplementation((...args) => {
+        const child = spawn(...args);
+        // Observe the real spawn error without letting it terminate the test runner.
+        child.once("error", resolve);
+        return child;
+      });
+    });
+    const result = yield* Command.runWith(uninstallCommand, { version: packageJson.version })([
+      "--base-dir",
+      baseDir,
+      "--yes",
+    ]).pipe(
+      Effect.result,
+      Effect.provideService(HostProcess.Environment, {
+        ComSpec: path.join(baseDir, "missing-cmd.exe"),
+      }),
+      Effect.provideService(HostProcess.Platform, "win32"),
+      Effect.provideService(HostProcess.IsExecutable, false),
+      Effect.provide(
+        Layer.mergeAll(
+          ConfigProvider.layer(ConfigProvider.fromEnv({ env: {} })),
+          Layer.fresh(TestConsole.layer),
+        ),
+      ),
+    );
+    yield* Effect.promise(() => failedSpawn);
+    expect(result._tag, "an unavailable cleanup shell must fail uninstall").toBe("Failure");
+  }).pipe(Effect.scoped, Effect.provide(Layer.mergeAll(NodeServices.layer, NetService.layer))),
+);
+
 it.layer(Layer.mergeAll(NodeServices.layer, NetService.layer))("t3 uninstall command", (it) => {
   it.effect("names another home's service it leaves installed", () =>
     Effect.gen(function* () {
cd apps/server && pnpm exec vp test run src/cli/uninstall.test.ts -t 'reports failure when the Windows cleanup shell cannot start'

Workaround

No response

Activity

  1. added
    vouch:trusted
    on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    vouch:trusted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions