Skip to content
Latchkey

Scala "could not find implicit value for parameter" in CI

A method takes an implicit (Scala 2) or given (Scala 3) parameter and the compiler could not find an instance of the required type in scope. The fix is to import or provide that instance.

What this error means

scalac fails with "could not find implicit value for parameter X: SomeType" (Scala 2) or "no given instance of type SomeType was found" (Scala 3) at a call that needs an implicit.

scalac
[error] /src/main/scala/Json.scala:9:26: could not find implicit value for parameter
encoder: io.circe.Encoder[MyCase]
[error]   payload.asJson
[error]                          ^

Common causes

The implicit instance is not imported

A typeclass instance exists in a companion or a syntax package but was never imported, so it is not in implicit scope at the call.

A derivation dependency is missing in CI

Automatic derivation needs an extra artifact (for example a -generic module) that is on the local machine but not declared, so no instance can be summoned.

How to fix it

Import or define the instance

  1. Read the required implicit type in the error.
  2. Import the package that provides it, or define the instance yourself.
  3. Recompile to confirm the implicit resolves.
Json.scala
import io.circe.generic.auto._ // derives Encoder/Decoder
payload.asJson

Add the derivation dependency

If derivation is automatic, declare the module that provides it so the instance can be generated in CI.

build.sbt
libraryDependencies += "io.circe" %% "circe-generic" % "0.14.6"

How to prevent it

  • Keep implicit/given imports beside the code that summons them.
  • Declare derivation modules explicitly in libraryDependencies.
  • Prefer explicit instances over wildcard imports for clarity in reviews.

Related guides

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