Skip to content
Latchkey

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

  1. Drop "shell: pwsh" and rely on the default bash shell, or set "shell: bash" explicitly.
  2. Translate any PowerShell cmdlets to their POSIX equivalents.
  3. 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

  1. Add a step that installs PowerShell Core on the custom runner before the pwsh step.
  2. Confirm "pwsh --version" succeeds.
  3. Re-run the pwsh step.
install pwsh
- run: |
    sudo apt-get update
    sudo apt-get install -y powershell
- shell: pwsh
  run: $PSVersionTable.PSVersion

How 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →