Skip to content
Latchkey

pre-commit "end-of-file-fixer...Failed" in CI

The end-of-file-fixer hook ensures each file ends in exactly one newline. When it has to change a file, it edits it and reports "Failed" with "files were modified by this hook", which fails the CI run because the working tree changed.

What this error means

pre-commit shows "end-of-file-fixer.........Failed" with "files were modified by this hook" and lists the files it fixed. Locally the fix is applied; in CI it fails because the change was not committed.

pre-commit
end-of-file-fixer........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing config.yaml

Common causes

A file has no final newline or has extra blank lines

The hook enforces exactly one trailing newline; a missing newline or multiple blank lines at EOF triggers a fix.

The fix was not committed before CI ran

pre-commit in CI runs the same hook; because it edits files, an uncommitted fix fails the check even though it "passed" after editing.

How to fix it

Run the hook locally and commit the result

  1. Run pre-commit run end-of-file-fixer --all-files locally.
  2. Stage and commit the files it modified.
  3. Push so CI runs against already-fixed files.
Terminal
pre-commit run end-of-file-fixer --all-files
git add -A && git commit -m "Normalize end-of-file newlines"

Install pre-commit as a git hook so it fixes on commit

Installing the hook means the fixer runs before each commit, so files reach CI already normalized.

Terminal
pre-commit install

How to prevent it

  • Install pre-commit locally so fixers run before every commit.
  • Enable "insert final newline" in your editor.
  • Commit the fixer's changes rather than pushing unfixed files.

Frequently asked questions

What causes ""end-of-file-fixer...Failed""?
The hook enforces exactly one trailing newline; a missing newline or multiple blank lines at EOF triggers a fix.
How do I fix "end-of-file-fixer...Failed"?
Run the hook locally and commit the result

Related guides

References

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