Skip to content
Latchkey

Elixir "(Mix) Could not compile dependency" in CI

Mix tried to compile one of your dependencies and its build exited non-zero. The real cause - a missing C compiler, a native library, or an incompatible Elixir/Erlang version - is in the output just above this line.

What this error means

mix deps.compile or compile fails with "** (Mix) Could not compile dependency :X, \"mix compile\" failed", often after a native or NIF build error.

elixir
** (Mix) Could not compile dependency :bcrypt_elixir, "mix compile" failed.
You can recompile this dependency with "mix deps.compile bcrypt_elixir --force",
update it with "mix deps.update bcrypt_elixir" or ...

Common causes

A native build needs a missing toolchain

A dependency with a NIF or C source needs make, a compiler, or -dev headers the runner image does not provide.

An Elixir/Erlang version mismatch

The dependency requires a newer Elixir or OTP than the runner provides, so its compile step fails.

How to fix it

Install the build prerequisites

  1. Read the captured error above the Mix summary.
  2. Install whatever it names - build-essential, make, or a -dev package.
  3. Re-run mix deps.compile <dep> --force.
Terminal
sudo apt-get update && sudo apt-get install -y build-essential

Match the required Elixir/OTP version

Set the runner to the Elixir and OTP the dependency supports so its compile succeeds.

.github/workflows/ci.yml
- uses: erlef/setup-beam@v1
  with:
    elixir-version: '1.16'
    otp-version: '26'

How to prevent it

  • Provide build tooling for dependencies with native code.
  • Pin Elixir and OTP versions the dependency tree supports.
  • Read the captured build error, not just the Mix summary line.

Related guides

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