cli: upgrade cannot detect npm installs on Windows (spawns .cmd shims without a shell)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 74/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript
- Domain
- cli
Research direction
Start by reading the install-method detection code that spawns npm, pnpm, bun, yarn, and vp, then compare it with postinstall.mjs, which the issue says already handles Windows npm shims. Check whether the install path has the same spawn behavior. Done means a global npm install is detected and upgrades on Windows without --method; verify with the issue’s reproduction steps.
Written by the indexing model from the issue text.
Description
Summary
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(oropencode 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):
subprocess.run(['npm','--version'], shell=False)-> FileNotFoundError / WinError 2.subprocess.run('npm --version', shell=True)->11.12.1.
(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.mjsalready 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 resolvenpm.cmdthrough ComSpec). - Workaround:
opencode upgrade --method npmbypasses detection. Note the install step DOES use a shell (its failures surface cmd.exe's "not recognized" error), so--methodworks 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>.cmdvia ComSpec.
- Dominant language
- TypeScript
- Stars
- 215k
- Forks
- 28.9k
- Avg merge
- 8h 11m
- Merged PRs (30d)
- 365
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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.
More from anomalyco/opencode
-
reproduced
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
anomalyco/opencode#57711 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
anomalyco/opencode#57698 · 3 comments ·
Maintainers usually reply within 1 day
-
pending close triaging
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
anomalyco/opencode#57664 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
anomalyco/opencode#57536 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
fs: /cd and file pickers fail on FreeBSD/ZFS — `stat` throws "dev exceeds the safe integer range" (fixed in @effect/platform-node-shared 4.0.5)Possibly taken @argszero claimed this today. Openreproduced
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
anomalyco/opencode#57518 · 3 comments · 1 reaction ·
Maintainers usually reply within 1 day
All issues in anomalyco/opencode
Similar issues
-
ready-for-agent
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
xavxyz/bei-shan-lin-shui#57 ·
Maintainers usually reply within 1 day
-
[BUG] rag: sentence content can cross the reported sentence boundariesPossibly taken @LJK-ikun claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
bug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
README: the Resource URI Schemas example's file://documents/* pattern only matches that literal URIOpen
Difficulty 1/5 Under an hour Newbie friendliness 88/100
platformatic/mcp#361 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
siyuan-note/siyuan#20799 · 7 comments ·
Maintainers usually reply within 1 day