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
OpenCode plugin: process.execPath is opencode.exe, not a JS runtime - all execFile calls fail silently #187
This assumes process.execPath is a Node or Bun binary that can execute JS files. In Claude Code that's true (process.execPath = node.exe), but in OpenCode it's the compiled binary:
OpenCode doesn't recognize wmux.js as a subcommand and prints its help page. The () => {} callback swallows the error, so the failure is completely silent.
Result: The sidebar stays stuck on "Running" and never transitions to "Done", "Needs you", or any other state.
Fix
Replace process.execPath with an actual Node binary when it doesn't point to a JS runtime. For example:
One thought — looking at this more closely, the plugin could potentially avoid the node dependency entirely by talking to the named pipe directly from within the plugin process. OpenCode's runtime supports node:net, so something like:
This is essentially what wmux-hook.js does under the hood. It would sidestep the process.execPath issue altogether and also be a bit faster since it avoids spawning a child process for every event.
Just an idea — the findNode() fix works fine as a pragmatic solution too.
Thanks @zutur — this is an excellent report, and the diagnosis was exactly right. Fixed in v1.9.0 (393ed65).
You found a hosting assumption, not just a bad line. process.execPath was a JS runtime by accident of the host: under Claude Code it happens to be node.exe, so the code shipped and looked fine. Under OpenCode it is the compiled binary and the whole bridge silently disappears — and the () => {} callback is why it stayed invisible for an entire release line, which is arguably the worse half of the bug.
I took your fix and pushed the resolution one step upstream. wmux spawns the pane, so it is the process best placed to answer "what can run a .js file on this machine", and it now does that once at launch and declares the answer to everything downstream:
WMUX_NODE=C:\Program Files\nodejs\node.exe
WMUX_NODE_ELECTRON= # 1 only when WMUX_NODE is wmux's own binary
The plugin's chain is now:
$WMUX_NODE — wmux already looked, and it could look in places a plugin cannot.
process.execPath, but only when its basename really is node/bun — your check, kept for a plugin installed by an older wmux.
Every PATH entry, then the default install dirs (%ProgramFiles%\nodejs, %LOCALAPPDATA%\Programs\nodejs, ~/.bun/bin, …) — which is the case you hit: node installed, just not on the PATH that process inherited.
Bare node.
The last resort on the wmux side is wmux's own binary, which is plain Node when spawned with ELECTRON_RUN_AS_NODE=1. So the chain can't dead-end even on a machine with no Node at all. That flag is also the difference between "a JS runtime" and "a second wmux window opens", which is why it travels as its own variable rather than being inferred from the path.
Two things came out of chasing it:
The wmux / wmux.cmd shims had the same latent bug. They ran bare node, i.e. the same assumption one layer down. They now prefer $WMUX_NODE and fall back to the old behaviour when it is absent.
wmux.cmd was one commit away from being LF-only, which cmd.exe "handles" by resuming mid-token — setlocal runs as tlocal, REM as M — while still reaching the last line. It half-works, so the only symptoms are stderr noise and a setlocal that never took. .gitattributes now pins eol=crlf instead of relying on core.autocrlf.
Covered by tests that load the shipped resources/opencode-plugin/wmux.js itself rather than a paraphrase of it — a one-token bug deserves a test that would actually have caught the one token — plus tests that run the real .cmd through cmd.exe and assert on argument quoting and CRLF.
The plugin carries a version marker, so wmux replaces the v2 copy in ~/.config/opencode/plugin/wmux.js on first launch. Nothing to do but update. And if it ever misbehaves again, WMUX_PLUGIN_DEBUG=1 now makes the plugin log failed CLI calls instead of swallowing them.
Activity
zutur commentedon Aug 22, 2026
One thought — looking at this more closely, the plugin could potentially avoid the node dependency entirely by talking to the named pipe directly from within the plugin process. OpenCode's runtime supports
node:net, so something like:This is essentially what
wmux-hook.jsdoes under the hood. It would sidestep theprocess.execPathissue altogether and also be a bit faster since it avoids spawning a child process for every event.Just an idea — the
findNode()fix works fine as a pragmatic solution too.fix(opencode): run the CLI through a real JS runtime, map ask/reply e…
amirlehmam commentedon Aug 22, 2026
Thanks @zutur — this is an excellent report, and the diagnosis was exactly right. Fixed in v1.9.0 (393ed65).
You found a hosting assumption, not just a bad line.
process.execPathwas a JS runtime by accident of the host: under Claude Code it happens to benode.exe, so the code shipped and looked fine. Under OpenCode it is the compiled binary and the whole bridge silently disappears — and the() => {}callback is why it stayed invisible for an entire release line, which is arguably the worse half of the bug.I took your fix and pushed the resolution one step upstream. wmux spawns the pane, so it is the process best placed to answer "what can run a
.jsfile on this machine", and it now does that once at launch and declares the answer to everything downstream:The plugin's chain is now:
$WMUX_NODE— wmux already looked, and it could look in places a plugin cannot.process.execPath, but only when its basename really isnode/bun— your check, kept for a plugin installed by an older wmux.PATHentry, then the default install dirs (%ProgramFiles%\nodejs,%LOCALAPPDATA%\Programs\nodejs,~/.bun/bin, …) — which is the case you hit: node installed, just not on the PATH that process inherited.node.The last resort on the wmux side is wmux's own binary, which is plain Node when spawned with
ELECTRON_RUN_AS_NODE=1. So the chain can't dead-end even on a machine with no Node at all. That flag is also the difference between "a JS runtime" and "a second wmux window opens", which is why it travels as its own variable rather than being inferred from the path.Two things came out of chasing it:
wmux/wmux.cmdshims had the same latent bug. They ran barenode, i.e. the same assumption one layer down. They now prefer$WMUX_NODEand fall back to the old behaviour when it is absent.wmux.cmdwas one commit away from being LF-only, whichcmd.exe"handles" by resuming mid-token —setlocalruns astlocal,REMasM— while still reaching the last line. It half-works, so the only symptoms are stderr noise and asetlocalthat never took..gitattributesnow pinseol=crlfinstead of relying oncore.autocrlf.Covered by tests that load the shipped
resources/opencode-plugin/wmux.jsitself rather than a paraphrase of it — a one-token bug deserves a test that would actually have caught the one token — plus tests that run the real.cmdthroughcmd.exeand assert on argument quoting and CRLF.The plugin carries a version marker, so wmux replaces the v2 copy in
~/.config/opencode/plugin/wmux.json first launch. Nothing to do but update. And if it ever misbehaves again,WMUX_PLUGIN_DEBUG=1now makes the plugin log failed CLI calls instead of swallowing them.Answering #188 separately.