Skip to content

Upgrade fails when opencode is installed via npm, and nodejs was installed via scoop #46493

Closed as not planned

Description

@ogerardin

Description

Note: this is a duplicate of #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
+-- [email protected]
# 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

  1. Install scoop https://scoop.sh/#/
  2. Install node.js using scoop: scoop install main/nodejs-lts
  3. Install opencode using npm: npm install -g opencode-ai
  4. 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

Activity

  1. MilkyWay008 commented on Sep 1, 2026

    @MilkyWay008

    The opencode upgrade scoop-vs-npm mixup is the install-detection code, your exec path sits under C:\Users\...\scoop\ so the scoop branch wins the sort, and scoop list opencode always prints that 'Installed apps matching' header, which is why the includes check never catches it. Workaround until it's patched: skip the built-in updater and run npm install -g opencode-ai@<version> yourself, or patch installation/index.ts to prefer npm whenever npm list -g --depth=0 shows opencode-ai. Fixed the same mess on my Windows box that way.

  2. ogerardin commented on Sep 1, 2026

    @ogerardin
    Author

    The opencode upgrade scoop-vs-npm mixup is the install-detection code, your exec path sits under C:\Users\...\scoop\ so the scoop branch wins the sort, and scoop list opencode always prints that 'Installed apps matching' header, which is why the includes check never catches it.

    Thank you, that's exactly what I explained above :)

    Workaround until it's patched: skip the built-in updater and run npm install -g opencode-ai@<version> yourself

    opencode upgrade -m npm works too, but it's annoying.

    or patch installation/index.ts to prefer npm whenever npm list -g --depth=0 shows opencode-ai.

    Could you elaborate please?

  3. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions