anomalyco / anomalyco/opencode
Upgrade fails when opencode is installed via npm, and nodejs was installed via scoop
@Hona is already working on this.
Since Aug 31, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
Note: this is a duplicate of https://github.com/anomalyco/opencode/issues/34734 which was closed for inactivity. I'm reopening it because the bug still exists.
Description
opencode upgrade incorrectly detects scoop as the installation method when opencode is installed via npm but Node.js itself is installed via scoop.
Environment
- OS: Windows 11
- opencode version: 1.18.25
- Installation method:
npm install -g opencode-ai - Node.js installation: via scoop (
scoop install nodejs-lts)
Root Cause
Two compounding issues in packages/opencode/src/installation/index.ts:
1. Exec path sort puts scoop first
The detection sorts package managers by whether their name appears in process.execPath. Because Node.js is installed via scoop, the opencode binary resolves to a path like:
C:\Users\<user>\scoop\apps\nodejs-lts\current\bin\node_modules\opencode-ai\bin\opencode.exe
This path contains scoop, so scoop is sorted to the front of the check list before npm.
2. scoop list opencode always outputs "opencode" in its header
scoop list opencode returns the following even when opencode is not installed via scoop:
Installed apps matching 'opencode':
The detection code checks output.includes("opencode"), which matches this header string regardless of whether any packages are listed. This causes a false positive: scoop is returned as the detected method even though opencode is not managed by scoop.
// In method():
const output = yield* check.command() // scoop list opencode
const installedName = check.name === "scoop" ? "opencode" : "opencode-ai"
if (output.includes(installedName)) { // always true due to header line
return check.name // incorrectly returns "scoop"
}
Verification
$ scoop list opencode
Installed apps matching 'opencode':
# (no entries - scoop does NOT manage opencode)
$ npm list -g --depth=0 | grep opencode
+-- opencode-ai@1.18.25
# npm IS managing opencode
Expected Behavior
opencode should detect npm as the installation method.
Actual Behavior
opencode upgrade attempts to upgrade via scoop (scoop install opencode@<version>) instead of npm (npm install -g opencode-ai@<version>).
Suggested Fix
For the scoop check, skip the header line before testing for a match:
// scoop list always emits: "Installed apps matching 'opencode':"
// filter that header out before checking for actual results
const lines = output.split("\n").filter(l => !l.startsWith("Installed apps matching"))
if (lines.some(l => l.includes("opencode"))) return "scoop"
Alternatively, prefer npm over scoop when npm list -g confirms opencode-ai is installed — a package named opencode-ai can only come from npm, not scoop.
Plugins
No response
OpenCode version
1.18.25
Steps to reproduce
- Install scoop https://scoop.sh/#/
- Install node.js using scoop:
scoop install main/nodejs-lts - Install opencode using npm:
npm install -g opencode-ai - Wait for an update to be available and try
opencode upgrade
Screenshot and/or share link
No response
Operating System
Windows 11
Terminal
Windows terminal
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.