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
- Read the captured error above the Mix summary.
- Install whatever it names -
build-essential,make, or a-devpackage. - Re-run
mix deps.compile <dep> --force.
Terminal
sudo apt-get update && sudo apt-get install -y build-essentialMatch 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
Elixir "(Mix) The task X could not be found" in CIFix Elixir "** (Mix) The task \"X\" could not be found" in CI - Mix has no task by that name because the prov…
Elixir "(CompileError) undefined function" in CIFix Elixir "** (CompileError) ... undefined function X/N" in CI - the compiler reached a call to a function w…
Elixir "mix deps.get ... no matching version" (Hex) in CIFix Elixir "Failed to use X because ... no matching version" during mix deps.get in CI - Hex could not find a…