Skip to content
Latchkey

ccache "command not found" on the runner in CI

Your build invokes ccache as the compiler launcher, but the runner has no ccache binary on PATH. Nothing was cached because the wrapper itself never ran.

What this error means

A compile step fails with "ccache: command not found" or "/bin/sh: 1: ccache: not found", usually right after CMake configured CMAKE_CXX_COMPILER_LAUNCHER=ccache or a Makefile set CC="ccache gcc".

ccache
/bin/sh: 1: ccache: not found
make: *** [Makefile:42: main.o] Error 127

Common causes

ccache is not installed on the image

The runner image ships gcc/clang but not ccache, so any launcher that shells out to ccache fails with exit 127.

ccache installed but not on PATH for this step

ccache was installed to a prefix (or a per-user bin) that the compile step's PATH does not include, so the shell cannot resolve it.

How to fix it

Install ccache before configuring the build

  1. Add a setup step that installs ccache from the package manager.
  2. Confirm it resolves with ccache --version.
  3. Only then configure CMake or Make to use it as the launcher.
.github/workflows/ci.yml
- name: Install ccache
  run: sudo apt-get update && sudo apt-get install -y ccache
- run: ccache --version

Use a maintained setup action

A dedicated action installs ccache and prepends it to PATH so both bare and launcher invocations resolve.

.github/workflows/ci.yml
- uses: hendrikmuhs/ccache-action@v1.2
  with:
    key: ${{ runner.os }}-ccache

How to prevent it

  • Install ccache in a setup step before any compile step references it.
  • Verify with ccache --version so a missing binary fails fast and clearly.
  • Bake ccache into custom runner images used for C/C++ builds.

Related guides

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