Skip to content

Commit 0ccf9bd

Browse files
feat(cli): uninstall opencode installed via windows package managers (anomalyco#8571)
1 parent ee4ea65 commit 0ccf9bd

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

packages/opencode/src/cli/cmd/uninstall.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ async function showRemovalSummary(targets: RemovalTargets, method: Installation.
133133
bun: "bun remove -g opencode-ai",
134134
yarn: "yarn global remove opencode-ai",
135135
brew: "brew uninstall opencode",
136+
choco: "choco uninstall opencode",
137+
scoop: "scoop uninstall opencode",
136138
}
137139
prompts.log.info(` ✓ Package: ${cmds[method] || method}`)
138140
}
@@ -182,16 +184,27 @@ async function executeUninstall(method: Installation.Method, targets: RemovalTar
182184
bun: ["bun", "remove", "-g", "opencode-ai"],
183185
yarn: ["yarn", "global", "remove", "opencode-ai"],
184186
brew: ["brew", "uninstall", "opencode"],
187+
choco: ["choco", "uninstall", "opencode"],
188+
scoop: ["scoop", "uninstall", "opencode"],
185189
}
186190

187191
const cmd = cmds[method]
188192
if (cmd) {
189193
spinner.start(`Running ${cmd.join(" ")}...`)
190-
const result = await $`${cmd}`.quiet().nothrow()
194+
const result =
195+
method === "choco"
196+
? await $`echo Y | choco uninstall opencode -y -r`.quiet().nothrow()
197+
: await $`${cmd}`.quiet().nothrow()
191198
if (result.exitCode !== 0) {
192-
spinner.stop(`Package manager uninstall failed`, 1)
193-
prompts.log.warn(`You may need to run manually: ${cmd.join(" ")}`)
194-
errors.push(`Package manager: exit code ${result.exitCode}`)
199+
spinner.stop(`Package manager uninstall failed: exit code ${result.exitCode}`, 1)
200+
if (
201+
method === "choco" &&
202+
result.stdout.toString("utf8").includes("not running from an elevated command shell")
203+
) {
204+
prompts.log.warn(`You may need to run '${cmd.join(" ")}' from an elevated command shell`)
205+
} else {
206+
prompts.log.warn(`You may need to run manually: ${cmd.join(" ")}`)
207+
}
195208
} else {
196209
spinner.stop("Package removed")
197210
}

0 commit comments

Comments
 (0)