GitHub Actions "pwsh: command not found" on an Ubuntu runner
A step declared "shell: pwsh" but the chosen runner image does not have PowerShell Core on PATH. GitHub-hosted Ubuntu images bundle pwsh, but custom or self-hosted runners may not.
What this error means
A step with "shell: pwsh" fails to start, reporting that pwsh cannot be found, even though "bash" steps run fine.
github-actions
/usr/bin/env: 'pwsh': No such file or directory
##[error]Process completed with exit code 127.Common causes
Self-hosted or custom image without pwsh
PowerShell Core is not part of the base OS. A runner image that was not provisioned with pwsh cannot run "shell: pwsh" steps.
Step assumes Windows shell semantics
A workflow copied from a Windows job kept "shell: pwsh" even though it now runs on ubuntu-latest, where bash is the natural default.
How to fix it
Use bash on Linux runners
- Drop "shell: pwsh" and rely on the default bash shell, or set "shell: bash" explicitly.
- Translate any PowerShell cmdlets to their POSIX equivalents.
- Re-run on ubuntu-latest.
.github/workflows/ci.yml
- name: Print version
shell: bash
run: cat package.json | grep '"version"'Install PowerShell if pwsh is required
- Add a step that installs PowerShell Core on the custom runner before the pwsh step.
- Confirm "pwsh --version" succeeds.
- Re-run the pwsh step.
install pwsh
- run: |
sudo apt-get update
sudo apt-get install -y powershell
- shell: pwsh
run: $PSVersionTable.PSVersionHow to prevent it
- Match the "shell:" value to what the runner image actually ships.
- Provision pwsh in your custom runner image if workflows rely on it.
Related guides
GitHub Actions "/usr/bin/bash: line N: command not found"Fix the GitHub Actions run-step error "/usr/bin/bash: line N: command not found" - the tool is not installed…
GitHub Actions "working-directory ... does not exist"Fix the GitHub Actions error where a step fails because its working-directory path does not exist on the runn…