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) mix format failed due to --check-formatted.
The following files are not formatted:
* lib/app/router.ex
* test/app/router_test.exsCommon 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.
mix format
git add -A && git commit -m "mix format"Align the formatter version and config
- Pin the same Elixir/OTP version in CI as developers use locally.
- Commit
.formatter.exsso line length andimport_depsare consistent. - Run
mix format --check-formattedas a pre-commit/pre-push hook.
How to prevent it
- Run
mix formatbefore committing (pre-commit hook). - Pin Elixir/OTP in CI to match local formatting output.
- Commit
.formatter.exsso style rules are shared.