Skip to content
Latchkey

sbt-assembly "deduplicate" Merge Conflict in CI

sbt-assembly is building a fat JAR and found two dependencies that contribute the same file path with different contents. It refuses to pick one silently and asks for a merge strategy.

What this error means

sbt assembly fails with "deduplicate: different file contents found in the following", listing a path (often META-INF/..., module-info.class, or reference.conf) present in multiple jars.

sbt output
[error] deduplicate: different file contents found in the following:
[error] .../netty-common-4.1.x.jar:META-INF/io.netty.versions.properties
[error] .../netty-handler-4.1.x.jar:META-INF/io.netty.versions.properties

Common causes

Two jars ship the same path

Multiple dependencies include the same resource (metadata, reference.conf, service files) with differing contents, so assembly cannot deduplicate automatically.

No merge strategy for the conflicting path

The default strategy errors on conflicts it does not know how to merge (e.g. module-info.class, duplicated META-INF entries).

How to fix it

Add a merge strategy for the path

Tell assembly how to handle the conflicting files - discard metadata, concat config, take first where safe.

build.sbt
// build.sbt
assembly / assemblyMergeStrategy := {
  case PathList("META-INF", xs @ _*) => MergeStrategy.discard
  case "module-info.class"           => MergeStrategy.discard
  case "reference.conf"              => MergeStrategy.concat
  case x =>
    val old = (assembly / assemblyMergeStrategy).value
    old(x)
}

Remove the duplicate dependency

  1. Check whether two versions of the same library are both on the classpath.
  2. Exclude or align them so the duplicate path disappears.
  3. Prefer fixing the dependency graph over masking it with discard.

How to prevent it

  • Keep a merge strategy for common META-INF/config conflicts.
  • Deduplicate library versions before reaching for discard.
  • Use concat for additive config files, not discard.

Frequently asked questions

What causes ""deduplicate" (assembly)"?
Multiple dependencies include the same resource (metadata, reference.conf, service files) with differing contents, so assembly cannot deduplicate automatically.
How do I fix "deduplicate" (assembly)?
Tell assembly how to handle the conflicting files - discard metadata, concat config, take first where safe.

Related guides

References

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