sbt cross-version / binary version conflict
Two artifacts on the classpath were compiled for different Scala binary versions. sbt refuses to mix, for example, _2.13 and _3 builds of the same library.
What this error means
update or eviction reporting fails with conflicting cross-version suffixes, naming the artifact and the two suffixes. It is deterministic given the dependency set.
[error] Modules were resolved with conflicting cross-version suffixes in ProjectRef:
[error] com.example:widget _2.13, _3Common causes
A dependency uses %% with a wrong scalaVersion
One library was added with a hardcoded suffix while the project moved to a different Scala version, so suffixes diverge.
A transitive dep pulls an incompatible build
A third-party library brings in another module built for a different Scala binary version.
How to fix it
Align all libraries to one Scala version
- Set a single
scalaVersionfor the project. - Use
%%everywhere so suffixes follow scalaVersion automatically. - Remove any hardcoded
_2.13/_3artifact names.
Find which dependency pulls the wrong build
Inspect the dependency tree to locate the offending transitive artifact.
sbt evicted
sbt "whatDependsOn com.example widget"Use the cross-compatible release
Upgrade the lagging library to a version published for your Scala binary version, or exclude the bad transitive and add the right one.
How to prevent it
- Standardize on one Scala version per build.
- Prefer %% over hardcoded suffixes.
- Review
sbt evictedafter dependency bumps.