Repository navigation
fix(desktop): resolve the terminal shell to an absolute path on Windows - #706
Merged
Merged
Conversation
`portable-pty` passes the program to `CreateProcessW` as `lpApplicationName`,
and Win32 does not search `PATH` for that parameter. `resolve_shell` handed
over the bare fallback names (`pwsh.exe` -> `powershell.exe` -> `cmd.exe`) and
skipped validation for them, so a machine without PowerShell 7 on `PATH` got
`os error 2` ("The system cannot find the file specified") for every terminal
tab, surfaced as `terminal.json`'s `createFailed` ("无法启动终端").
Resolve each Windows candidate to an absolute path that exists before it is
offered - `PATH` in the OS's own order (tolerating quoted entries) with the
usual launch extensions, then the well-known install locations
(%ProgramFiles%\PowerShell\7\pwsh.exe, System32\WindowsPowerShell\v1.0\
powershell.exe, System32\cmd.exe / %COMSPEC%) - and fall through to the next
candidate instead of spawning a name that cannot be launched. `list_shells`
reports the same absolute paths. Unix behaviour is unchanged.
The regression is pinned by `terminal::shell::windows_tests`; the resolver
itself takes the environment as a parameter so those rules are testable
without mutating the process `PATH`.
ace331
enabled auto-merge (squash)
September 17, 2026 11:09
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
portable-ptypasses the program toCreateProcessWaslpApplicationName, and Win32 does not searchPATHfor that parameter.resolve_shellhanded over the bare fallback names (pwsh.exe->powershell.exe->cmd.exe) and skipped validation for them, so a machine without PowerShell 7 onPATHgotos error 2("The system cannot find the file specified") for every terminal tab, surfaced asterminal.json'screateFailed("无法启动终端").Resolve each Windows candidate to an absolute path that exists before it is offered -
PATHin the OS's own order (tolerating quoted entries) with the usual launch extensions, then the well-known install locations (%ProgramFiles%\PowerShell\7\pwsh.exe, System32\WindowsPowerShell\v1.0\ powershell.exe, System32\cmd.exe / %COMSPEC%) - and fall through to the next candidate instead of spawning a name that cannot be launched.list_shellsreports the same absolute paths. Unix behaviour is unchanged.The regression is pinned by
terminal::shell::windows_tests; the resolver itself takes the environment as a parameter so those rules are testable without mutating the processPATH.