Skip to content
Latchkey

sbt "missing or invalid dependency detected while loading class" in CI

scalac tried to read a class file that references another class not on the compile classpath, or one compiled against an incompatible version. The class graph is inconsistent.

What this error means

Compilation fails with missing or invalid dependency detected while loading class file X.class, naming the missing referenced class. It is deterministic given the dependency set.

sbt
[error] missing or invalid dependency detected while loading class file 'Widget.class'.
[error] Could not access type Codec in package io.example,
[error] because it (or its dependencies) are missing.
[error] full classpath may be missing io.example:codec_2.13

Common causes

A transitive dependency is not on the classpath

A library you depend on was compiled against another module that is absent from your build, so scalac cannot resolve a referenced type.

Binary-incompatible versions

A dependency was built against a different major version of a shared library than the one you resolved, leaving missing or renamed classes.

How to fix it

Add the missing transitive dependency

Declare the module the class file references so scalac can read it.

build.sbt
libraryDependencies += "io.example" %% "codec" % "2.4.0"

Align shared library versions

  1. Run sbt evicted to spot conflicting versions of the shared library.
  2. Pin a single compatible version across all dependencies.
  3. Upgrade the lagging library to one built against your version.

How to prevent it

  • Review sbt evicted after dependency bumps.
  • Pin shared libraries to one consistent version.
  • Prefer dependencies published for your Scala version.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →