Repository navigation
Closed
Description
Summary
The companion currently spawns opencode, node, and which directly. On Windows, npm-global binaries are usually .cmd shims (opencode.cmd, node may be outside the minimal PATH, etc.), and Node's spawn() with shell: false does not resolve .cmd wrappers.
This is the OpenCode equivalent of several upstream Codex plugin Windows issues.
Local evidence
Affected paths include:
plugins/opencode/scripts/lib/process.mjsresolveOpencodeBinary()usesspawn("which", ["opencode"])getOpencodeVersion()usesspawn("opencode", ["--version"])runCommand()usesspawn(cmd, args, ...)without Windows shim handlingspawnDetached()usesspawn(cmd, args, ...)for backgroundnode
plugins/opencode/scripts/lib/opencode-server.mjsensureServer()usesspawn("opencode", ["serve", ...])
Expected behavior
Setup and runtime commands should work on Windows when OpenCode was installed through npm or another shim-based installer.
Suggested fix
Add a shared spawn helper that handles Windows command resolution deliberately:
- Prefer direct executable resolution where possible (
where opencodeon Windows,command -v/whichelsewhere). - For npm
.cmdshims, useshell: trueor resolve the concrete.cmdpath only where needed. - Preserve UNC/network-drive behavior by avoiding blanket
shell: truefor all git subprocesses. - Add regression coverage around the command-building behavior.
Upstream references
Derived from these applicable upstream issues:
- Windows: spawnSync ENOENT — codex/npm not detected without shell:true openai/codex-plugin-cc#16
/codex:setupreports npm and codex as "Missing" / "Not installed" on Windows (Claude Code + Git Bash) openai/codex-plugin-cc#17- spawn codex ENOENT on Windows — app-server.mjs missing shell: true for .cmd wrapper resolution openai/codex-plugin-cc#32
- Windows:
spawn codex ENOENT— missingshell: truein app-server.mjs openai/codex-plugin-cc#46 - spawn codex ENOENT on Windows: companion script fails to find codex CLI openai/codex-plugin-cc#50
- spawn() in app-server.mjs fails with ENOENT on Windows openai/codex-plugin-cc#53
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]Windows: opencode/node process spawning fails for npm .cmd shims[/-][+]Portable process spawning across macOS and Windows[/+]JohnnyVicious commentedon Apr 12, 2026
Consolidating #18 and #46 here. The canonical scope is portable process invocation: Windows npm .cmd shims, Windows shell/SHELL behavior, and macOS Claude Code App minimal PATH/bare-node failures. Command-markdown quoting remains tracked separately in #29.
JohnnyVicious commentedon Apr 12, 2026
Fixed by PR #51 commit f8d3fcc — platformShellOption() picks false on POSIX and $SHELL||true on win32; uses 'where' instead of 'which' on win32; applied to runCommand, spawnDetached, resolveOpencodeBinary, getOpencodeVersion, and ensureServer.