Skip to content

Windows: opencode upgrade fails to detect installation method (returns unknown) #17295

Closed

Description

@Raviguntakala

Description

On Windows, opencode upgrade fails to detect the installation method and returns "unknown". This causes the upgrade command to show:

x  opencode is installed to C:\Users\...\opencode-windows-x64\bin\opencode.exe and may be managed by a package manager

o  Install anyways?
|  No

Instead of detecting the correct method (e.g. npm) and proceeding with the upgrade.

Root cause: Installation.method() in src/installation/index.ts uses Process.text() which calls child_process.spawn() to run commands like npm list -g. On Windows, npm is actually npm.cmd (a .cmd batch file). child_process.spawn() without shell: true cannot resolve .cmd/.bat files, so every detection command silently fails (returns empty output due to nothrow: true), and method() falls through to "unknown".

The same issue affects all Windows package managers that use .cmd wrappers: npm, pnpm, bun.

Fix: Pass shell: process.env.ComSpec || "cmd.exe" (or shell: true) on Windows when spawning detection and upgrade commands. The path-based fallback detection (checking exec.includes("node_modules")) partially mitigates but does not cover all installation paths.

Plugins

No response

OpenCode version

1.2.25

Steps to reproduce

  1. Install opencode on Windows via npm: npm install -g opencode-ai
  2. Run opencode upgrade
  3. Observe error message about "may be managed by a package manager" instead of detecting npm as the method

Screenshot and/or share link

PS C:\Users\ravi.guntakala> opencode upgrade

                                   ▄
  █▀▀█ █▀▀█ █▀▀█ █▀▀▄ █▀▀▀ █▀▀█ █▀▀█ █▀▀█
  █  █ █  █ █▀▀▀ █  █ █    █  █ █  █ █▀▀▀
  ▀▀▀▀ █▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀

T  Upgrade
|
x  opencode is installed to C:\Users\ravi.guntakala\AppData\Roaming\npm\node_modules\opencode-ai\node_modules\opencode-windows-x64\bin\opencode.exe and may be managed by a package manager
|
o  Install anyways?
|  No
|
—  Done

Operating System

Windows 11

Terminal

PowerShell / Windows Terminal

Activity

  1. github-actions commented on Mar 13, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. added a commit that references this issue on Mar 13, 2026
    095c089
  3. nonoDamn commented on Mar 16, 2026

    @nonoDamn

    +1

  4. denprog5 commented on Mar 16, 2026

    @denprog5

    same

  5. amr616d720a0a-rgb commented on Mar 17, 2026

    @amr616d720a0a-rgb

    use npm update -g opencode-ai it solves the problem

  6. lazyalex616 commented on Mar 18, 2026

    @lazyalex616

    Additional context: this regression was introduced by PR #16286 (refactor(opencode): replace Bun shell in core flows, merged 2026-03-09), which replaced Bun's $ shell template (which resolves .cmd files through the system shell) with Process.spawn() (Node.js child_process.spawn) without shell: true.

    Note that this also affects Installation.upgrade() — even if method() were fixed, Process.run(["npm", "install", "-g", ...]) would still fail for the same reason.

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions