Skip to content
Latchkey

sbt-assembly "deduplicate: different file contents found" in CI

sbt-assembly builds a fat jar and found the same file path in two or more dependency jars with different contents. Its default strategy cannot pick one, so it fails and lists the conflicting jars. You resolve it with a merge strategy for that path.

What this error means

The assembly task fails with "deduplicate: different file contents found in the following:" followed by two or more jar paths for the same resource (often module-info.class or reference.conf).

sbt-assembly
[error] deduplicate: different file contents found in the following:
[error] .../jackson-core-2.15.2.jar:module-info.class
[error] .../jackson-databind-2.15.2.jar:module-info.class

Common causes

Two jars ship the same path with different bytes

Files like module-info.class, reference.conf, or META-INF entries appear in multiple dependencies with differing contents, so a plain copy is ambiguous.

No merge strategy declared for the path

The default deduplicate strategy errors on differing content; you must tell assembly how to merge or which copy to keep.

How to fix it

Declare a merge strategy for the conflicting paths

  1. Read the conflicting path from the error.
  2. Add an assemblyMergeStrategy case for it (discard, concat, or first).
  3. Re-run assembly to confirm the jar builds.
build.sbt
assembly / assemblyMergeStrategy := {
  case PathList("module-info.class") => MergeStrategy.discard
  case "reference.conf" => MergeStrategy.concat
  case x =>
    val old = (assembly / assemblyMergeStrategy).value
    old(x)
}

Remove the duplicate at its source

If the duplicate comes from an unwanted transitive jar, exclude it so only one copy of the path remains.

build.sbt
libraryDependencies += ("com.x" %% "y" % "1.0")
  .exclude("com.fasterxml.jackson.core", "jackson-core")

How to prevent it

  • Declare assemblyMergeStrategy cases for common conflicts (reference.conf, module-info.class).
  • Keep the fat-jar dependency set minimal to reduce path collisions.
  • Build the assembly in CI so merge conflicts surface before release.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →