Skip to content
Latchkey

scalafmt check failed in CI

scalafmt ran in check mode and found files that do not match the configured formatting. This is a style gate, not a compile failure.

What this error means

The CI step fails with a list of files that are not formatted, telling you to run scalafmt. It is deterministic given the sources and .scalafmt.conf.

sbt
[error] /src/main/scala/App.scala isn't formatted properly!
[error] --- a/src/main/scala/App.scala
[error] +++ b/src/main/scala/App.scala
[error] scalafmt: 1 files must be formatted

Common causes

Code committed without formatting

A change was pushed without running scalafmt, so the files diverge from the configured style.

scalafmt version or config drift

A different scalafmt version (or a changed .scalafmt.conf) formats differently than what produced the committed code, so CI flags files that look fine locally.

How to fix it

Format the sources

Run scalafmt to rewrite files to the configured style, then commit.

CI step
sbt scalafmtAll scalafmtSbt

Pin the scalafmt version

  1. Set the exact version in .scalafmt.conf with version = "...".
  2. Use the same version locally and in CI.
  3. Run a format-on-save or pre-commit hook to stay in sync.

How to prevent it

  • Pin the scalafmt version in .scalafmt.conf.
  • Add a pre-commit or format-on-save hook.
  • Run scalafmtCheckAll locally before pushing.

Frequently asked questions

What causes ""scalafmt: files must be formatted""?
A change was pushed without running scalafmt, so the files diverge from the configured style.
How do I fix "scalafmt: files must be formatted"?
Run scalafmt to rewrite files to the configured style, then commit.

Related guides

References

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