-
-
Notifications
You must be signed in to change notification settings - Fork 68.8k
[Bug]: resolvePowerShellPath() on Windows ignores PowerShell 7, defaults to PS 5.1 #25638
Copy link
Copy link
Closed
Closed
Copy link
Description
Description
On Windows, resolvePowerShellPath() in the exec runtime always resolves to PowerShell 5.1 (powershell.exe) even when PowerShell 7 (pwsh.exe) is installed at C:\Program Files\PowerShell\7\pwsh.exe.
This causes exec tool commands using && operator to fail silently or error out, because PowerShell 5.1 does not support && (pipeline chain operators were introduced in PowerShell 7).
Steps to Reproduce
- Install OpenClaw on Windows 11 with PowerShell 7 installed
- Run any exec command using
&&(e.g.cd /path && ls) - The command fails because it's executed via PS 5.1 which doesn't support
&&
Current Behavior
resolvePowerShellPath() checks:
SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe(PS 5.1)- Falls back to
"powershell.exe"
PowerShell 7 (pwsh.exe / C:\Program Files\PowerShell\7\pwsh.exe) is never checked.
Expected Behavior
resolvePowerShellPath() should prioritize PowerShell 7 when available:
- Check
C:\Program Files\PowerShell\7\pwsh.exefirst - Then fall back to PS 5.1
Suggested Fix
function resolvePowerShellPath() {
// Prefer PowerShell 7 (supports && operator, better compatibility)
const pwsh7 = "C:\Program Files\PowerShell\7\pwsh.exe";
if (fs.existsSync(pwsh7)) return pwsh7;
// Fallback to PS 5.1
const systemRoot = process.env.SystemRoot || process.env.WINDIR;
if (systemRoot) {
const candidate = path.join(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe");
if (fs.existsSync(candidate)) return candidate;
}
return "powershell.exe";
}Environment
- OS: Windows 11 Home 10.0.26200
- OpenClaw: 2026.2.17+
- PowerShell 7.5 installed at
C:\Program Files\PowerShell\7\ - Node.js: v22.x
Workaround
Currently patching resolvePowerShellPath() in dist files after each update via sed/script, but this breaks on every npm update.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Give feedbackNo fields configured for issues without a type.