Repository navigation
fix(cli): t3 uninstall on Windows removes the downloaded runtime #24874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,6 +66,20 @@ export const findOwnedLauncher = Effect.fn("cli.uninstall.find_launcher")(functi | |
| return launcherOwnsVersionsDir(path, input.versionsDir, resolved) ? input.launchedAs : undefined; | ||
| }); | ||
|
|
||
| /** | ||
| * Removes `dir` from a detached cmd.exe about two seconds later, once t3 has exited. `shell` makes | ||
| * Node pass cmd the line verbatim as `/d /s /c "<line>"`. As a plain argument, the quotes around | ||
| * `dir` would reach cmd escaped as `\"`, which cmd keeps literally, so `rmdir` would fail. | ||
| */ | ||
| export function spawnWindowsRemoval(comspec: string, dir: string) { | ||
| return NodeChildProcess.spawn(`ping -n 3 127.0.0.1 >nul & rmdir /s /q "${dir}"`, { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep the runtime path literal in the shell command. If
|
||
| shell: comspec, | ||
| detached: true, | ||
| stdio: "ignore", | ||
| windowsHide: true, | ||
| }); | ||
| } | ||
|
|
||
| const planUninstall = Effect.fn("cli.uninstall.plan")(function* (input: { | ||
| readonly baseDir: string; | ||
| }) { | ||
|
|
@@ -183,14 +197,7 @@ const runUninstall = Effect.fn("cli.uninstall.run")(function* (input: { | |
| const runtimeDir = plan.runtimeDir; | ||
| const comspec = environment["ComSpec"] ?? environment["COMSPEC"] ?? "cmd.exe"; | ||
| yield* Effect.try({ | ||
| try: () => { | ||
| const child = NodeChildProcess.spawn( | ||
| comspec, | ||
| ["/d", "/c", `ping -n 3 127.0.0.1 >nul & rmdir /s /q "${runtimeDir}"`], | ||
| { detached: true, stdio: "ignore", windowsHide: true }, | ||
| ); | ||
| child.unref(); | ||
| }, | ||
| try: () => spawnWindowsRemoval(comspec, runtimeDir).unref(), | ||
| catch: () => | ||
| new CliUninstallError({ | ||
| reason: `Could not schedule removal of ${runtimeDir}. Delete it yourself once this window is closed.`, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 Critical
cli/uninstall.ts:75When
dircontains%USERNAME%,cmd.exeexpands it beforermdirruns, so uninstallingC:\t3-%USERNAME%\runtimedeletesC:\t3-Alice\runtimewhenUSERNAME=Alice—a potentially unconfirmed directory. Becausediris interpolated into command source, quoting does not prevent percent expansion; pass the path as data and disable delayed expansion.🤖 Copy this AI Prompt to have your agent fix this: