Description
On v2.2.6, when "shell": "pwsh" is the value that takes effect and PowerShell 7 comes only from the Microsoft Store, every shell command returns exit=0 with empty output. The resolver hands the app-execution alias to spawn instead of a real executable:
command="C:\Users\<user>\AppData\Local\Microsoft\WindowsApps\Microsoft.PowerShell_8wekyb3d8bbwe\pwsh.exe"
Before v2.2.6 the same config fell back to Windows PowerShell 5.1 — the wrong shell, but commands ran and their output came back. That is exactly what #55255 reported. #61952 fixed the detection and turned the symptom into a silent failure, which is worse: the tool reports success, the model receives an empty result and reasons over "nothing" instead of seeing an error.
Setting "shell" to the packaged exe path makes the same commands work again, so the whole difference is the resolved path.
Environment
- opencode 2.2.6, installed via npm global
- Windows 11 (10.0.26300); only the TUI/CLI is installed, there is no desktop app on this machine
- PowerShell 7.6.9 installed from the Microsoft Store only —
Test-Path 'C:\Program Files\PowerShell\7\pwsh.exe' returns False, so pwsh.exe exists only as an app-execution alias under %LOCALAPPDATA%\Microsoft\WindowsApps
- config:
"shell": "pwsh" in ~/.config/opencode/opencode.jsonc
- plugin:
opencode-windows-encoding (prepends UTF-8 setup; present before and after the upgrade, unrelated)
Steps to reproduce
- On Windows 11, install PowerShell 7 from the Microsoft Store only.
- Make sure the effective
"shell" is the bare name "pwsh" — and that no other config document overrides it with a rooted path (a project-level opencode.jsonc takes precedence over the global one; see the note at the end).
- Run any command through the shell tool, e.g.
echo probe.
Result, every time: status=exited, exit=0, output.size=0, and the per-call file under <data>/shell/<hash>/*.out is 0 bytes. No error is surfaced anywhere.
Evidence
Two runs on the same machine, one minute apart, with only the effective "shell" differing:
| time (UTC) |
effective "shell" |
spawn command |
output |
| 05:36:22 / 05:36:25 |
rooted packaged path |
C:/Program Files/WindowsApps/Microsoft.PowerShell_7.6.9.0_x64__8wekyb3d8bbwe/pwsh.exe |
87 B / 506 B — ok |
| 05:36:49 / 05:36:56 / 05:37:07 |
"pwsh" |
C:\Users\<user>\...\WindowsApps\Microsoft.PowerShell_8wekyb3d8bbwe\pwsh.exe |
0 / 0 / 0 — exit 0, empty |
session_message rows and the log agree, and the row for (Get-Process -Id $PID).Path is empty too — not a single byte arrives from the child process.
Raw spawning process lines (username replaced with <user>, timestamps UTC):
# failing — alias path
timestamp=2026-11-07T05:36:49.970Z level=INFO run=f771ddc9 message="spawning process" command="C:\\Users\\<user>\\AppData\\Local\\Microsoft\\WindowsApps\\Microsoft.PowerShell_8wekyb3d8bbwe\\pwsh.exe" args="[\"-NoLogo\",\"-NoProfile\",\"-NonInteractive\",\"-Command\",\"...;\\necho probe\"]" cwd="C:\\Users\\<user>\\Desktop" role=server
# working — rooted packaged path
timestamp=2026-11-07T05:36:25.199Z level=INFO run=62f23242 message="spawning process" command="C:/Program Files/WindowsApps/Microsoft.PowerShell_7.6.9.0_x64__8wekyb3d8bbwe/pwsh.exe" args="[\"-NoLogo\",\"-NoProfile\",\"-NonInteractive\",\"-Command\",\"...;\\n$PSVersionTable\"]" cwd="C:\\Users\\<user>\\Desktop" role=server
Note the shapes: the failing path uses backslashes and sits under %LOCALAPPDATA%; the working path uses forward slashes and is a config literal. which() and the alias fallback both join with Windows semantics and can only emit backslashes, so a forward-slash path is never a resolution result — that is how the two cases can be told apart at a glance in a log.
The child is not hanging: each failing call completes in about 250 ms with exit=0 (from session_message.time.created → time.completed). The output is simply not delivered.
Why this is a regression from #61952
Before #61952, which() had no alias fallback. With the alias invisible to which, executable() returned nothing and select() fell through win() to findExecutable("powershell") — Windows PowerShell 5.1 — which ran commands and returned their output. That is the behaviour described in #55255.
#61952 added:
packages/core/src/util/which.ts — which() now returns appExecutionAlias(...), i.e. the alias path itself
packages/core/src/shell/select.ts — if (isAppExecutionAlias(shell) || stat(shell)?.isFile()) return shell
So the alias — a path that cannot be stat-ed as a regular file — is now accepted as the shell and passed to spawn. Nothing between resolution and spawn checks that the returned path actually produces output.
Implementation problems around that fix
isAppExecutionAlias() accepts any symlink (lstatSync(file)?.isSymbolicLink() === true && existsSync(file)) instead of checking the IO_REPARSE_TAG_APPEXECLINK reparse tag, and its lstatSync is not guarded against EACCES — see issue #62501 for the malformed path that crashes it (...\WindowsApps\python.exe\pwsh.exe).
- The shell is accepted without any check that it can be
stat-ed as a regular file, so an unusable path is indistinguishable from a usable one.
- The tests added in fix(core): find Microsoft Store PowerShell 7 on Windows #61952 assert
resolve(...) === alias.file and which(...) === alias.file — that the resolver echoes its input. They cannot fail for the reason this issue fails. test.skipIf(!alias) also skips them on any machine without a Store app installed, which is most CI.
What a fix should hold
- Never hand an
IO_REPARSE_TAG_APPEXECLINK path to spawn. Resolve it to the packaged exe first (GetPackageFullNameFromFamilyName + GetPackagePathByFullName, or scan C:\Program Files\WindowsApps\Microsoft.PowerShell_*_x64__8wekyb3d8bbwe), and if that fails, fall back with a warning or return an error — never a silent success.
- Don't cache the resolved package path — see service: cached Store pwsh path goes stale after package update #56381 / Windows: shell runs PowerShell 5.1 with a Store-installed pwsh 7, and a Store update strands the cached path #56738.
- Test behaviour, not identity. Spawn the resolved path and assert stdout (
-Command 'echo ok'); keep a unit-level invariant that the resolver only returns paths that stat reports as regular files.
opencode debug shell printing the resolved path, the config document that supplied "shell", and a spawn smoke test. On this machine the hardest thing to find was a project-level config document silently supplying a rooted path; one such command would have shown it immediately.
Note on how this was first reported
The first revision of this issue described the failure as intermittent and included a table that attributed the difference to the opencode version. Both were wrong: the "working" runs were using a rooted path from a project-level opencode.jsonc (not "shell": "pwsh"), and the version table compared two different configs. With that document out of the way, the failure reproduces every time. The report above is the corrected version.
Related: #55255 #61952 #62501 #56381 #56738