Skip to content
Latchkey

Elixir "mix format --check-formatted" Fails in CI

CI ran mix format --check-formatted and found files that do not match the formatter’s output. The check makes no changes - it fails if any file would be reformatted.

What this error means

mix format --check-formatted exits non-zero and lists files that are "not formatted". It happens when code was committed without running the formatter, or a different Elixir/formatter version reformats differently.

mix output
** (Mix) mix format failed due to --check-formatted.
The following files are not formatted:
  * lib/app/router.ex
  * test/app/router_test.exs

Common causes

Code committed without formatting

The formatter was not run before committing, so the files differ from mix format output and the check fails.

Formatter config or version drift

A different Elixir version, or a changed .formatter.exs (line length, imported deps), reformats differently than the committed code expects.

How to fix it

Format locally and commit

Run the formatter, then commit the result so the check passes.

Terminal
mix format
git add -A && git commit -m "mix format"

Align the formatter version and config

  1. Pin the same Elixir/OTP version in CI as developers use locally.
  2. Commit .formatter.exs so line length and import_deps are consistent.
  3. Run mix format --check-formatted as a pre-commit/pre-push hook.

How to prevent it

  • Run mix format before committing (pre-commit hook).
  • Pin Elixir/OTP in CI to match local formatting output.
  • Commit .formatter.exs so style rules are shared.

Frequently asked questions

What causes ""mix format --check-formatted""?
The formatter was not run before committing, so the files differ from mix format output and the check fails.
How do I fix "mix format --check-formatted"?
Run the formatter, then commit the result so the check passes.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card