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.
[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.13Common 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.
libraryDependencies += "io.example" %% "codec" % "2.4.0"Align shared library versions
- Run
sbt evictedto spot conflicting versions of the shared library. - Pin a single compatible version across all dependencies.
- Upgrade the lagging library to one built against your version.
How to prevent it
- Review
sbt evictedafter dependency bumps. - Pin shared libraries to one consistent version.
- Prefer dependencies published for your Scala version.