Skip to content
Latchkey

Elixir "(CompileError)" in CI

The Elixir compiler rejected your source. A CompileError means a real problem in the code - an undefined function or module, a bad alias, or warnings promoted to errors in CI.

What this error means

mix compile fails with "** (CompileError) lib/foo.ex:12: undefined function bar/1" or a similar message pointing at a file and line. It is deterministic - the same code fails the same way every time.

mix output
== Compilation error in file lib/app/worker.ex ==
** (CompileError) lib/app/worker.ex:12: undefined function process/1
    (expected App.Worker to define such a function or for it to be imported)

Common causes

Undefined function, module, or alias

A call to a function/module that does not exist (typo, removed API, missing alias/import), or a macro used before it is required, fails at compile time.

Warnings treated as errors in CI

Many pipelines compile with --warnings-as-errors. Code that compiles locally with warnings then fails the CI build on those same warnings.

How to fix it

Fix the reported code

A CompileError points at a file and line - correct the undefined reference, add the missing alias/import, or define the function. This is source, not a flake, so do not retry.

Reproduce the CI flags locally

Compile with the same strictness CI uses so warnings surface before you push.

Terminal
mix compile --warnings-as-errors --force

How to prevent it

  • Run mix compile --warnings-as-errors locally to match CI.
  • Keep aliases/imports current when refactoring modules.
  • Use mix xref/mix dialyzer to catch undefined calls early.

Related guides

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