Skip to content
Latchkey

GitHub Actions "/usr/bin/bash: line N: command not found"

A run step invoked a binary the runner cannot resolve. Bash searches PATH, finds nothing, and exits the step with code 127. The shell itself is fine; the named command is missing or misspelled.

What this error means

A run step fails immediately on the line that calls a CLI tool, printing the tool name followed by "command not found".

github-actions
/usr/bin/bash: line 2: pnpm: command not found
##[error]Process completed with exit code 127.

Common causes

Tool was never installed on the runner

The image does not ship the binary, and no setup-* step (or install command) ran before the step that uses it.

Tool installed but not added to PATH

An installer placed the binary in a custom directory that was not appended to GITHUB_PATH, so later steps cannot see it.

Typo in the command name

A misspelled binary (for example "pyhton" or "yanr") never matches anything on PATH.

How to fix it

Install the tool before you use it

  1. Add the relevant setup action or install command as an earlier step in the same job.
  2. Confirm the version line runs successfully before the failing step.
  3. Re-run; the binary now resolves on PATH.
.github/workflows/ci.yml
- uses: pnpm/action-setup@v4
  with:
    version: 9
- run: pnpm --version
- run: pnpm install --frozen-lockfile

Add a custom install dir to PATH

  1. Append the install directory to GITHUB_PATH in the install step.
  2. PATH changes via GITHUB_PATH apply to subsequent steps, not the current one.
  3. Re-run and verify the command resolves.
install + GITHUB_PATH
- run: |
    curl -sSL https://example.com/install.sh | sh -s -- --bin-dir "${HOME}/.local/bin"
    echo "${HOME}/.local/bin" >> "${GITHUB_PATH}"
- run: mytool --version

How to prevent it

  • Pin a setup action for every toolchain your workflow depends on.
  • Print "tool --version" right after install to fail fast with a clear message.

Frequently asked questions

What causes ""/usr/bin/bash: line N: command not found""?
The image does not ship the binary, and no setup-* step (or install command) ran before the step that uses it.
How do I fix "/usr/bin/bash: line N: command not found"?
Install the tool before you use it

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card