Skip to content
Latchkey

Bun "bun: command not found" in CI

The shell could not find a bun executable on PATH. In CI this almost always means the oven-sh/setup-bun step never ran, failed, or a job on a fresh runner is calling Bun before it is installed.

What this error means

A step running bun install or bun run build fails with "bun: command not found" and exit code 127, even though the workflow looks correct.

Terminal
/home/runner/work/_temp/xxxx.sh: line 1: bun: command not found
Error: Process completed with exit code 127.

Common causes

setup-bun never ran before the Bun step

The oven-sh/setup-bun step is missing, is in a different job, or is ordered after the step that calls bun, so nothing put Bun on PATH.

The install step failed silently or PATH was lost

setup-bun failed to download the release, or a later shell/container step does not inherit the PATH entry the action exported.

How to fix it

Add oven-sh/setup-bun before any bun step

  1. Add the setup-bun action to the same job, before the first bun call.
  2. Pin a version so downloads are deterministic.
  3. Verify with a bun --version step immediately after setup.
.github/workflows/ci.yml
- uses: oven-sh/setup-bun@v2
  with:
    bun-version: '1.1.34'
- run: bun --version
- run: bun install

Install Bun directly in a container job

When the job runs inside a container that setup-bun cannot modify, install Bun with the official script and export its bin directory.

.github/workflows/ci.yml
- run: |
    curl -fsSL https://bun.sh/install | bash
    echo "$HOME/.bun/bin" >> "$GITHUB_PATH"

How to prevent it

  • Keep setup-bun as the first step of every job that uses Bun.
  • Pin bun-version so a bad release cannot break the install.
  • Add a bun --version smoke step to catch PATH problems early.

Related guides

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