fix(shell): prefer PowerShell 7 on Windows, fall back to PS 5.1#25684
Closed
zerone0x wants to merge 1 commit intoopenclaw:mainfrom
Closed
fix(shell): prefer PowerShell 7 on Windows, fall back to PS 5.1#25684zerone0x wants to merge 1 commit intoopenclaw:mainfrom
zerone0x wants to merge 1 commit intoopenclaw:mainfrom
Conversation
When PowerShell 7 (pwsh.exe) is installed, resolvePowerShellPath() now returns it instead of defaulting to PS 5.1 (powershell.exe). PS 5.1 does not support the && pipeline chain operator, causing exec commands like `cd /path && ls` to fail silently on Windows 11 hosts where PS 7 is available. Resolution order: 1. %ProgramFiles%\PowerShell\7\pwsh.exe (standard PS 7 install) 2. %ProgramW6432%\PowerShell\7\pwsh.exe (ARM64 / WoW64) 3. pwsh found on PATH (winget / scoop / custom locations) 4. %SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe (PS 5.1) 5. powershell.exe (bare name fallback) Also exports resolvePowerShellPath() and adds unit tests covering the new priority order (Windows-only tests guarded by isWin). Fixes openclaw#25638 Co-Authored-By: Claude <[email protected]>
steipete
added a commit
that referenced
this pull request
Feb 25, 2026
Contributor
|
Reviewed and reimplemented on What shipped:
Validation:
Thanks for the issue and patch direction, @zerone0x. |
Contributor
|
Landed on main in fa525bf with tested PS7-first shell resolution; closing in favor of landed commit. |
joshavant
pushed a commit
that referenced
this pull request
Feb 25, 2026
margulans
pushed a commit
to margulans/Neiron-AI-assistant
that referenced
this pull request
Feb 25, 2026
Jackson3195
pushed a commit
to Jackson3195/openclaw-with-a-personal-touch
that referenced
this pull request
Feb 25, 2026
kevinWangSheng
pushed a commit
to kevinWangSheng/openclaw
that referenced
this pull request
Feb 26, 2026
kevinWangSheng
pushed a commit
to kevinWangSheng/openclaw
that referenced
this pull request
Feb 26, 2026
brianleach
pushed a commit
to brianleach/openclaw
that referenced
this pull request
Feb 26, 2026
2 tasks
execute008
pushed a commit
to execute008/openclaw
that referenced
this pull request
Feb 27, 2026
r4jiv007
pushed a commit
to r4jiv007/openclaw
that referenced
this pull request
Feb 28, 2026
zooqueen
pushed a commit
to hanzoai/bot
that referenced
this pull request
Mar 6, 2026
thebenjaminlee
pushed a commit
to escape-velocity-ventures/openclaw
that referenced
this pull request
Mar 7, 2026
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.
Summary
resolvePowerShellPath()always selected PS 5.1 (powershell.exe), even when PowerShell 7 (pwsh.exe) was installed. PS 5.1 does not support the&&pipeline chain operator, so exec commands likecd /path && lsfail silently on Windows 11 hosts with PS 7 present.&&chaining in all exec tool calls.resolvePowerShellPath()now probes for PS 7 first via standard install paths and PATH, then falls back to PS 5.1.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
On Windows hosts with PowerShell 7 installed, the exec tool now runs commands through
pwsh.exe(PS 7) instead ofpowershell.exe(PS 5.1). The&&operator and other PS 7 features work as expected.Security Impact (required)
Repro + Verification
Environment
C:\Program Files\PowerShell\7\pwsh.exeSteps
&&: e.g.cd /tmp && ls&&)&&)Expected
Command with
&&executes correctly.Actual (before fix)
PS 5.1 silently fails or errors on
&&.Evidence
isWin).uses PowerShell on Windowscontinues to pass (path still containsPowerShell).Human Verification (required)
ProgramW6432, custom PATH install (scoop/winget), no PS7 present.Compatibility / Migration
Failure Recovery (if this breaks)
src/agents/shell-utils.tsRisks and Mitigations
Greptile Summary
resolvePowerShellPath()now prioritizes PowerShell 7 (pwsh.exe) over PowerShell 5.1 (powershell.exe) on Windows to enable support for the&&pipeline chain operator. The function checks standard PS7 install paths, ARM64/WoW64 alternate paths, PATH lookup for custom installations (scoop/winget), and falls back to PS5.1 when PS7 is not found.cd /path && lsthat fail silently on Windows 11 with PS7 installedConfidence Score: 5/5
&&operators fail on Windows 11 machines with PowerShell 7 installed.Last reviewed commit: e6391dd