Skip to content

spawn("opencode") fails with ENOENT on Windows (npm .cmd shims need shell: true) #8

Description

@roend83

On Windows, every companion command (/opencode:setup, /opencode:review, /opencode:rescue, background serve) fails immediately with:

Error: spawn opencode ENOENT

even when OpenCode is correctly installed via npm install -g opencode-ai and resolvable on PATH.

Root cause: npm installs global CLI shims on Windows as opencode.cmd / opencode.ps1 (there's no extensionless opencode executable). child_process.spawn(\"opencode\", ...) without shell: true can't resolve those shims on Windows — it only works for a real executable. This affects every spawn(\"opencode\", ...) call in scripts/lib/process.mjs and scripts/lib/opencode-server.mjs.

Separately, the install-check in resolveOpencodeBinary() shells out to which opencode, but which isn't a native Windows binary, so the check reports "not installed" even when OpenCode is present.

Opened PR #7 with the fix: add shell: process.platform === \"win32\" to the four affected spawn() calls, and use where instead of which on win32. Tested locally on Windows 11 with OpenCode 1.18.9 — setup --json now returns a correct installed: true result instead of throwing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions