Repository navigation
Open
Description
Summary
On Windows, every shell tool call in a session fails instantly with the raw Windows error The system cannot find the path specified. (exit 1) — before the command runs. Pinning an absolute shell path in config ("shell": "C:\\Program Files\\PowerShell\\7\\pwsh.exe") immediately fixes it via hot-reload, which points at shell resolution selecting a non-functional executable (cached at process start) rather than a cwd/spawn problem.
Environment
- opencode version: v2.0.29
- OS: Windows 11 (10.0.26300.9550, win32 x64)
- Terminal: TUI running in Windows Terminal (
WT_SESSIONset;TERM=xterm-256color;OPENCODE=1) - Shell:
C:\windows\system32\cmd.exe(ambient at session start);$env:SHELLunset;pwsh7.6.6 and Gitbash.exeboth installed and present on disk - Install/channel: release
- Active plugins: none configured in
opencode.json
Reproduction
- Start the OpenCode background service on Windows (TUI client in Windows Terminal). No
shellkey in config. - In a session, invoke the
shelltool with any command (e.g.echo hello), with or without an explicitworkdirpointing at an existing directory. - Every call returns
The system cannot find the path specified.+Exited with code 1, instantly. - Add
"shell": "C:\\Program Files\\PowerShell\\7\\pwsh.exe"to the globalopencode.json. After hot-reload, the same calls succeed. Removing the key reverts to the failure after the next hot-reload (verified in the same running process).
Expected Behavior
The shell tool resolves a valid, working shell executable and runs the command; if resolution fails it should re-resolve (or surface a clear error naming the resolved path), not emit the raw OS error on every call.
Actual Behavior
Every spawn fails with:
The system cannot find the path specified.
Exited with code 1
Evidence that resolution — not the working directory — is at fault:
pwsh.exe(C:\Program Files\PowerShell\7\pwsh.exe) andbash.exeboth exist on disk and execute normally; noshelloverride was configured at the time of failure.- The failure began ~1 hour after the service was started and nothing about the installed shells changed on the machine in that window — so this is not a "path existed at startup and was later removed" scenario; the resolver picked a non-working executable from the start.
- The
workdirparameter (set to existing directories) did not change the outcome. session_moveof the affected session to an existing directory did not help.- Setting an absolute
shellpath in config fixed all calls immediately after config hot-reload — no service restart needed — and removing it re-broke them, showing the configured path bypasses a process-lifetime resolution cache.
Additional Context
- Possibly related: Windows: pwsh installed as a Store app-execution alias is not resolved, so the shell falls back to Windows PowerShell 5.1 #55255 (shell resolution misses Store app-execution aliases and silently falls back — the reporter's
pwshis a regular install atC:\Program Files\PowerShell\7, but the same silent-fallback code path may be involved), cli: no way to refresh environment variables without restarting #48919 (environment changes aren't picked up without restarting the service). - The error text matches what
cmd.exeprints when the executable it was asked to run doesn't exist, consistent with the spawn wrapper invoking a resolved-but-nonfunctional shell path. - Suggested hardening: (1) validate the resolved shell executable exists and actually spawns before caching it, and re-resolve on failure; (2) when resolution yields no usable executable, emit a warning naming what was tried instead of falling back silently; (3) include the resolved shell path in the shell tool error output.
- Workaround that fully restores function: set
"shell"to an absolute path in global config. - Frequency: observed on v2.0.29 from the first shell call of a session (~1 hour into a fresh service start); persists for the life of the service process until a
shellis configured. Not yet reproduced underOPENCODE_LOG_LEVEL=DEBUGto identify the exact resolved value.
Metadata
Metadata
Assignees
Labels
No labels
Activity
opencode-agent commentedon Oct 15, 2026
Thanks for the detailed report. I couldn't try to reproduce this, because it only happens on Windows (it showed up in the desktop app's background service after a few days) and our test environment is Linux, so it will need a maintainer with a Windows machine.
Some notes from reading the code, for whoever picks it up. None of this is confirmed:
shellis configured, the resolved shell is cached for the whole server process and never refreshed. A configuredshellskips that cache, which would explain why your workaround works after a hot-reload without a restart.cmd.exe(viaCOMSPEC). The error textThe system cannot find the path specified.looks likecmd.exe's own message rather than a failure to start the process. Socmd.exemay have been picked and then hit a path that didn't exist.If it happens again before you set the workaround, any log lines from that session about the shell or the instance would help.
Related:
pwshUntil then, setting
"shell"to an absolute path in your global config works around it, as you found.hrabbach commentedon Oct 15, 2026
Correction to my previous comment — please disregard its speculation.
Corrected facts (verified with the reporter):
pwsh7.6.6 (C:\Program Files\PowerShell\7\pwsh.exe) and Gitbash.exeexist and execute fine. So the "cached path stopped existing / Git moved" narrative was unfounded, and the earlier shell activity seen in the log belonged to a previous service run, not this one.shellconfigured, every shell tool call fails withThe system cannot find the path specified.+ exit 1 (includingecho hello, with or without a validworkdir). Toggling"shell": "C:\\Program Files\\PowerShell\\7\\pwsh.exe"in global config off/on via config hot-reload toggles the failure in the same running process — broken without the key, working with it.shellbypasses the cache entirely. Both plausible pwsh/bash candidates exist on disk, so whatever the resolver picked, it wasn't a usable one — consistent with the silent-fallback weakness inshell/select.ts(cf. Windows: pwsh installed as a Store app-execution alias is not resolved, so the shell falls back to Windows PowerShell 5.1 #55255), but the exact resolved value is unconfirmed.Next step if useful: run a fresh
opencode --standalone(or restarted service) withOPENCODE_LOG_LEVEL=DEBUGon this machine to capture exactly what the resolver selects at startup. Happy to do that on request.And to restate the earlier point with the corrected timeline: since the bad resolution is cached at process start, the practical impact is that a machine where resolution goes wrong gets a completely broken shell tool — for every project, every command — with an error message that names no path and hints at no config remedy.
hrabbach commentedon Oct 15, 2026
Update after a debug capture session — the plot thickens in a useful way.
What we did: killed the affected service (
opencode.exe serve --service, started ~1 h before the failure) and started a fresh one withOPENCODE_LOG_LEVEL=DEBUG/--print-logs, with noshellconfigured (the config workaround removed).Result: on the fresh service, the shell tool works. The debug log shows serve-mode resolution picking the exact expected binary:
Earlier, a fresh
opencode run --standalone(noshellconfigured, env inherited from the service) resolved the samepwsh.EXEand worked as well.Conclusion so far:
runandserve --servicemodes, in the service's own environment.shell).Practical notes for whoever picks this up:
The system cannot find the path specified., exit 1) for the life of the service process — severe but recoverable."shell"to an absolute path in global config (hot-reload bypasses the cache). A service restart also clears it.echo hello) suggests the cached value was a path that did not exist at spawn time.Reporter's config is back to no
shellkey and shell is working; will update if the failure reappears and a capture of the poisoned state becomes possible.