ultraworkers/claw-code · error · std::io::Error
PowerShell executable not found (expected `pwsh` or `powersh
Error message
PowerShell executable not found (expected `pwsh` or `powershell` in PATH)
What it means
Returned by detect_powershell_shell in the tools crate when neither pwsh nor powershell can be found. Note the implementation probes via command_exists(), which runs `sh -lc 'command -v <name> >/dev/null 2>&1'` — so detection requires a POSIX sh, and it only sees executables on the PATH that sh inherits. The error is io::Error with ErrorKind::NotFound.
Source
Thrown at rust/crates/tools/src/lib.rs:6586
if let Some(output) = workspace_test_branch_preflight(&input.command) {
return Ok(output);
}
let shell = detect_powershell_shell()?;
execute_shell_command(
shell,
&input.command,
input.timeout,
input.run_in_background,
)
}
fn detect_powershell_shell() -> std::io::Result<&'static str> {
if command_exists("pwsh") {
Ok("pwsh")
} else if command_exists("powershell") {
Ok("powershell")
} else {
Err(std::io::Error::new(
std::io::ErrorKind::NotFound,
"PowerShell executable not found (expected `pwsh` or `powershell` in PATH)",
))
}
}
fn command_exists(command: &str) -> bool {
std::process::Command::new("sh")
.arg("-lc")
.arg(format!("command -v {command} >/dev/null 2>&1"))
.status()
.is_ok_and(|status| status.success())
}
#[allow(clippy::too_many_lines)]
fn execute_shell_command(
shell: &str,
command: &str,View on GitHub (pinned to 08106b0c37)
Solutions
- Install PowerShell and verify the probe can see it: pwsh --version, or command -v pwsh inside `sh -l` (login shell) since that is exactly how detection runs
- Fix PATH so the login shell resolves pwsh: export PATH="$PATH:/usr/bin" with a symlink, or add the install dir to /etc/profile.d if sh -l strips it
- Don't request PowerShell on hosts without it — use the default bash/sh shell tool instead
- For Windows targets, install PowerShell 7 (pwsh) so the fallback to powershell.exe is unnecessary
Example fix
# before claw> run in powershell: Get-Location # -> NotFound: PowerShell executable not found # after (Ubuntu) sudo apt-get install -y powershell # or: brew install powershell on macOS sh -lc 'command -v pwsh' # verify the exact probe detection uses claw> run in powershell: Get-Location
Defensive patterns
Strategy: fallback
Validate before calling
fn powershell_available() -> bool {
// mirrors detect_powershell_shell's probe exactly: sh -lc 'command -v ...'
["pwsh", "powershell"].iter().any(|cmd| {
std::process::Command::new("sh")
.arg("-lc")
.arg(format!("command -v {cmd} >/dev/null 2>&1"))
.status()
.is_ok_and(|s| s.success())
})
}
if !powershell_available() { /* route to bash/sh tool instead */ } Type guard
fn detect_shell() -> &'static str {
if powershell_available() { "pwsh" } else { "bash" }
} Try / catch
match detect_powershell_shell() {
Ok(shell) => run_in_shell(shell, command),
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {
// fall back to the POSIX shell tool; PowerShell is simply absent
run_in_shell("bash", command)
}
Err(e) => Err(e),
} Prevention
- Verify with the exact probe the tool uses: sh -lc 'command -v pwsh' — a plain `pwsh` in your interactive shell can succeed while the login-shell PATH differs
- Install PowerShell on hosts that must run PS commands (apt/brew install powershell) and ensure it lands on the login-shell PATH
- Default agent prompts to bash/sh unless the task genuinely needs PowerShell
When it happens
Trigger: Invoking the PowerShell-capable shell tool (the Bash-tool family entry point at tools/lib.rs:6580 that dispatches to detect_powershell_shell) on a Linux box with no PowerShell installed, or anywhere PATH does not contain pwsh/powershell (container images, minimal CI runners, nix shells without the powershell package). Also on Windows hosts lacking a POSIX sh, since the probe itself runs through `sh -lc`.
Common situations: Debian/Ubuntu/Alpine containers without powershell installed; macOS without brew install powershell; CI runners where PowerShell is present but not on the PATH that sh -l resolves (login-shell PATH rewriting); asking the agent to run a PowerShell command by mistake on a Linux host.
Related errors
- skill source '{}' not found: {e}
- old_string not found in file
- HOME is not set (on Windows, set USERPROFILE or HOME, or use
- credentials file must contain a JSON object
- session file was removed during save (possible concurrent mo
AI-assisted analysis of ultraworkers/claw-code@08106b0c37 (2026-08-18).
Data as JSON: /api/errors/c34575435e55105d.
Report an issue: GitHub.