etspaceman / scalacheck-faker

Fake Data Generation using ScalaCheck
https://etspaceman.github.io/scalacheck-faker/
MIT License
40 stars 6 forks source link

"Missing class: pureconfig/Derivation" when trying to instantiate Gen[FirstName] #258

Closed kibebr closed 2 years ago

kibebr commented 2 years ago

Hi! When I try to construct an Arbitrary:

val nameGen = Arbitrary.arbitrary[faker.name.FirstName]

the following error is thrown:

A needed class was not found. This could be due to an error in your runpath. Missing class: pureconfig/Derivation
java.lang.NoClassDefFoundError: pureconfig/Derivation

I'm not sure what I can do here; I do have the pureconfig library if that's what's needed. Example of code:

import faker._
import faker.ResourceLoader
import org.scalatest._
import org.scalatest.funspec.AnyFunSpec
import org.scalacheck.{Arbitrary, Gen}
import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks

object UKResourceLoader {
  implicit val UKResourceLoader: ResourceLoader = ResourceLoader.en_GB
}

class Spec extends AnyFunSpec with GivenWhenThen with ScalaCheckPropertyChecks {
  import UKResourceLoader._

  describe("test") {
    it("should work") {
      val name = Arbritary[name.FirstName]
    }
  }
}
etspaceman commented 2 years ago

Is it possible that you have multiple versions of pureconfig in your classpath here? You can see that I have tests for this here:

https://github.com/etspaceman/scalacheck-faker/blob/master/src/test/scala/faker/FakerSpec.scala#L188

kibebr commented 2 years ago

@etspaceman

Removing pureconfig from my build.sbt fixed it. I have no idea where pureconfig is coming from now, but it now works, and that's all that matters.

Thanks for the library!

ewerkema commented 1 year ago

I am running into the same issue of java.lang.NoClassDefFoundError: pureconfig/Derivation. For me there seems no way to resolve this issue since I am forced to use a newer version of com.github.pureconfig in my project dependencies (namely 0.17.4). I tried including an exclusion rule exclude("com.github.pureconfig", "pureconfig") for Scalacheck, but this did not resolve the issue. Any tips on how to resolve this problem?

etspaceman commented 1 year ago

@ewerkema I will release a new version soon that brings in the newest pureconfig.