com-lihaoyi / fastparse

Writing Fast Parsers Fast in Scala
https://com-lihaoyi.github.io/fastparse
MIT License
1.09k stars 164 forks source link

SBT version conflict error when fastparse and os-lib are used together #265

Closed nemoo closed 1 year ago

nemoo commented 1 year ago

SBT version is 1.8.0.

Here is build.sbt:

lazy val root = project
  .in(file("."))
  .settings(
    scalaVersion := "2.13.10",
    libraryDependencies ++= Seq(
      "com.lihaoyi"   %% "os-lib"   % "0.9.0",
      "com.lihaoyi"   %% "fastparse"  % "2.3.3",
    )
  )

The error:

[error] java.lang.RuntimeException: found version conflict(s) in library dependencies; some are suspected to be binary incompatible:
[error]
[error]         * com.lihaoyi:geny_2.13:1.0.0 (early-semver) is selected over 0.6.10
[error]             +- com.lihaoyi:os-lib_2.13:0.9.0                      (depends on 1.0.0)
[error]             +- com.lihaoyi:fastparse_2.13:2.3.3                   (depends on 0.6.10)
[error]
[error]
[error] this can be overridden using libraryDependencySchemes or evictionErrorLevel
DougC commented 1 year ago

Same issue with scalatags and fastparse in newer sbt versions.

bwbecker commented 1 year ago

Same issue for me with scalatags and fastparse. I've been looking into libraryDependencySchemes but there is precious little documentation on the web. A search at scala-sbt.org turns up nothing. What I have found suggests that adding libraryDependencySchemes += "com.lihaoyi" %% "geny" % VersionScheme.Always should do it, but I haven't gotten it to work.

Update on the above: It appears that libraryDependencySchemes works on the JVM but I'm using the combination in a ScalaJS + JVM project. I'm just getting the error for the ScalaJS side of things. See my StackOverflow post at https://stackoverflow.com/questions/75229578/how-to-use-sbts-librarydependencyscheme-key

bwbecker commented 1 year ago

I did more work to confirm an SBT bug. libraryDependencySchemes can serve as a workaround to this library conflict in a JVM project but does not work in a Scala.JS project. See my bug report.

bwbecker commented 1 year ago

Here's a sketch of my work-around:

  1. Fork the fastparse library. Check it out to your local machine.
  2. In build.sc, I changed:
    -val scala213 = "2.13.6"
    -val scalaJS1 = "1.7.1"
    +val scala213 = "2.13.10"
    +val scalaJS1 = "1.12.0"

    and

    -    ivy"com.lihaoyi::sourcecode::0.2.3",
    -    ivy"com.lihaoyi::geny::0.6.10"
    +    ivy"com.lihaoyi::sourcecode::0.3.0",
    +    ivy"com.lihaoyi::geny::1.0.0"
  3. Commit the changes.
  4. Assign a tag in git. I used "2.3.3a" to remind myself that it was a custom version. This is important because mill gets the version number from the most recent tag.
  5. Publish the artifacts locally with ./mill "fastparse.js[2.13.10].publishLocal" and ./mill "fastparse.js[2.13.10,1.12.0].publishLocal"
  6. Adjust the library dependency in your project
  7. Cross your fingers, reload, and compile your project
lefou commented 1 year ago

Fixed in #271