You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cli: upgrade cannot detect npm installs on Windows (spawns .cmd shims without a shell) #57579
opencode upgrade / update on Windows always fails with "Could not detect the installation method" for npm-based installs, because install-method detection spawns npm/pnpm/yarn without a shell, and Windows cannot launch .cmd shims that way. --method npm bypasses detection, but the detection bug remains.
Environment
opencode version: 2.1.1 (also reproduced on 2.0.32 and 2.1.0)
OS: Microsoft Windows [Version 10.0.26200.9457] (Windows 11 25H2, x64)
Terminal: xterm-256color via agent harness; also fails headless (opencode update --print-logs)
Shell: C:\WINDOWS\system32\cmd.exe
Install/channel: release, npm install -g @opencode/cli (global prefix under the user profile)
Active plugins: none found in config
Reproduction
On Windows, npm install -g @opencode/cli.
Run opencode update (or opencode upgrade).
Detection tries npm/pnpm/bun/yarn/vp and reports "Could not detect the installation method."
Minimal proof the spawn mode is the cause (healthy minimal PATH where where npm succeeds):
(bun, a real .exe, spawns fine but correctly reports "not installed via bun".)
Expected Behavior
Detection recognizes the global npm install and upgrades it without requiring --method.
Actual Behavior
Could not detect the installation method. Pass --method to choose how to upgrade OpenCode.
The debug log shows spawning process command=npm args=["list","-g","--depth=0","@opencode/cli"] failing, because npm resolves to npm.cmd, which CreateProcess cannot launch directly (it only resolves .exe).
Additional Context
Consistently reproducible (2.0.32, 2.1.0, 2.1.1).
The project's own postinstall.mjs already documents this: "Windows cannot spawn npm's .cmd shim directly, so reuse the npm CLI that runs this script" via [process.execPath, process.env.npm_execpath]. Detection needs the same treatment (shell on win32, or resolve npm.cmd through ComSpec).
Workaround: opencode upgrade --method npm bypasses detection. Note the install step DOES use a shell (its failures surface cmd.exe's "not recognized" error), so --method works as long as the user's PATH is healthy; it fails only when PATH itself is broken (separate local issue on my machine: an over-long PATH).
Suggested fix: spawn package managers with a shell on Windows in both the detection and install paths, or invoke <mgr>.cmd via ComSpec.
Thanks for the detailed report. I couldn't reproduce this here, because it depends on how Windows resolves npm to npm.cmd and on PATH lookup, and my test environment only runs Linux. A maintainer with a Windows machine will need to look at it.
One thing that would help them: OpenCode doesn't start the package managers the way a plain subprocess.run(..., shell=False) does. It uses cross-spawn, which is meant to find .cmd shims through PATH and PATHEXT. So the Python test may not show the cause. Could you run opencode update --print-logs again from a shell with a short, healthy PATH, the same one where where npm works, and say whether detection still fails? If it only fails with your long PATH, that would point to the PATH problem you mentioned rather than the way npm is started.
Activity
opencode-agent commentedon Oct 21, 2026
Thanks for the detailed report. I couldn't reproduce this here, because it depends on how Windows resolves
npmtonpm.cmdand on PATH lookup, and my test environment only runs Linux. A maintainer with a Windows machine will need to look at it.One thing that would help them: OpenCode doesn't start the package managers the way a plain
subprocess.run(..., shell=False)does. It usescross-spawn, which is meant to find.cmdshims through PATH and PATHEXT. So the Python test may not show the cause. Could you runopencode update --print-logsagain from a shell with a short, healthy PATH, the same one wherewhere npmworks, and say whether detection still fails? If it only fails with your long PATH, that would point to the PATH problem you mentioned rather than the way npm is started.Related:
Until then,
opencode upgrade --method npmis the workaround, as you noted.