Skip to content

on Scala 2.11, version 1.1.2 may run afoul of sbt classpath issue #197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Philippus opened this issue Apr 6, 2019 · 15 comments
Closed

on Scala 2.11, version 1.1.2 may run afoul of sbt classpath issue #197

Philippus opened this issue Apr 6, 2019 · 15 comments

Comments

@Philippus
Copy link
Member

Philippus/bump#8 fails with the following exception in scala 2.11:

SemVer.nextStable removes pre-release information if available: Exception raised on property evaluation.
[info] > Exception: java.lang.AbstractMethodError: nl.gn0s1s.bump.SemVerParser$.scala$util$parsing$combinator$Parsers$$lastNoSuccessVar()Lscala/util/DynamicVariable;

Looks like #108 after testing locally.

Scala 2.12 and 2.13.0-RC1 are ok.

@SethTisue
Copy link
Member

SethTisue commented Apr 6, 2019

the root cause is that the Scala 2.11 compiler itself has a dependency on scala-parser-combinators. that dependency was removed in 2.12.

the problem goes away if you set fork in Test := true, because then the compiler and its dependencies aren't on the classpath

previously here in this repo: #13

and, we went through this before with scala-xml at scala/scala-xml#195 /cc @ashawley

@SethTisue
Copy link
Member

@eed3si9n why is this still happening even after sbt/zinc#505 ? the bump repo is on sbt 1.2.8, which includes the fix

@SethTisue
Copy link
Member

SethTisue commented Apr 6, 2019

the Shapeless repo only uses scala-parser-combinators in some example code, so this won't flow downstream to Shapeless users /cc @milessabin

specs2 has a scala-parser-combinators dependency, but fwiw it looks like it's only used by certain matcher types /cc @etorreborre

@SethTisue
Copy link
Member

SethTisue commented Apr 6, 2019

if a project has trouble it can always set fork ... (on 2.11 only, or build-wide). or add 1.1.1 or 1.1.2 to the classpath depending on whether they're on 2.13 or not, there are scenarios in which that wouldn't be okay. such scenarios are probably rare? but it does seem a bit dodgy

anyway, it seems like we should back-publish 1.1.1 for 2.13.0-RC1 so people will be less likely to be bitten. the underlying cause affects all scala-parser-combinators versions that aren't 1.04 (the version the 2.11 compiler uses), but the lastNoSuccessVar change in 1.1.2 seems to have made actual ensuing breakage much likelier

@SethTisue SethTisue changed the title Possible regression in version 1.1.2 for scala 2.11 on Scala 2.11, version 1.1.2 is likelier than previous versions to run afoul of sbt classpath issue Apr 6, 2019
@SethTisue SethTisue changed the title on Scala 2.11, version 1.1.2 is likelier than previous versions to run afoul of sbt classpath issue on Scala 2.11, version 1.1.2 may run afoul of sbt classpath issue Apr 6, 2019
xerial added a commit to xerial/airframe that referenced this issue Apr 6, 2019

Verified

This commit was signed with the committer’s verified signature.
xerial Taro L. Saito
Scala 2.11 + scala-parser-combinator + sbt class loader conflicts
@xerial
Copy link

xerial commented Apr 6, 2019

I hit this issue and switching 1.1.1 or 1.1.2 or using fork in True can be tricky.

@SethTisue
Copy link
Member

SethTisue commented Apr 6, 2019

I hit this issue and switching 1.1.1 or 1.1.2 or using fork in True can be tricky.

Yeah. Perhaps people landing on this ticket would like to leave links with sample diffs from their projects, to help others do likewise.

Also, this is obvious once you've understood the issue, but it's probably worth stating plainly:

Unless you fork, or until we have an sbt release with a fix, your tests aren't testing what they're supposed to be testing. They're testing something else. This was true already on 1.1.1 and previous versions too. It didn't start with the release of 1.1.2.

xerial added a commit to wvlet/airframe that referenced this issue Apr 7, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
* Upgrade to Scala 2.13.0-RC1

* Fix scalajs-java-logging version

* Add workaround for scala/scala-parser-combinators#197

Scala 2.11 + scala-parser-combinator + sbt class loader conflicts

* Read SQL files with Resource to support forked mode
@xerial
Copy link

xerial commented Apr 7, 2019

@SethTisue That's true.

Although it might have some overhead, adding fork in Test := True is most reliable to isolate libraries used in sbt and target applications.

@eed3si9n
Copy link
Member

eed3si9n commented Apr 7, 2019

@SethTisue It's an sbt bug.

So basically sbt/zinc#505 fixed the bug for run

   def makeLoader(classpath: Seq[File], instance: ScalaInstance): ClassLoader =
-    filterByClasspath(classpath, makeLoader(classpath, instance.loader, instance))
+    filterByClasspath(classpath, makeLoader(classpath, instance.loaderLibraryOnly, instance))

but didn't for test it seems.

https://github.com/sbt/sbt/blob/v1.2.8/testing/src/main/scala/sbt/TestFramework.scala#L258

    val dual = new DualLoader(
      scalaInstance.loader,

I opened sbt/sbt#4609.

@SethTisue
Copy link
Member

(closing the ticket since the bug isn't in this repo. still good we have this ticket to help searchers)

masahitojp added a commit to masahitojp/solr-scala-client that referenced this issue Apr 11, 2019
on Scala 2.11, version 1.1.2 may run afoul of sbt classpath issue #197
scala/scala-parser-combinators#197
Sciss added a commit to Sciss/scalariform that referenced this issue Apr 21, 2019
- update some dependencies (minor versions)
- careful with scala/scala-parser-combinators#197
jtjeferreira added a commit to jtjeferreira/scalaxb that referenced this issue Jul 22, 2019
we need to fork integration test because scala/scala-parser-combinators#197
@OlegYch
Copy link

OlegYch commented Feb 22, 2020

so, is 1.1.2 compatible with 1.0.4 or not? is 1.1.1 compatible with 1.0.4?

@OlegYch
Copy link

OlegYch commented Feb 22, 2020

ok, i did some tests and see that while technically a lib compiled against 1.0.4 (play_2.11-2.5.18) still references a method which is no longer available it seems to never be called

private DynamicVariable scala$util$parsing$combinator$Parsers$$lastNoSuccessVar$lzycompute() { synchronized (this) { if (!this.bitmap$0) { this.scala$util$parsing$combinator$Parsers$$lastNoSuccessVar = Parsers.class.scala$util$parsing$combinator$Parsers$$lastNoSuccessVar(this); this.bitmap$0 = true; } return this.scala$util$parsing$combinator$Parsers$$lastNoSuccessVar; }  } 
public DynamicVariable<Option<Parsers.NoSuccess>> scala$util$parsing$combinator$Parsers$$lastNoSuccessVar() { return this.bitmap$0 ? this.scala$util$parsing$combinator$Parsers$$lastNoSuccessVar : scala$util$parsing$combinator$Parsers$$lastNoSuccessVar$lzycompute(); } 

@OlegYch
Copy link

OlegYch commented Feb 23, 2020

then again, i'm not sure why would not-forking cause a problem...

@SethTisue
Copy link
Member

i'm not sure why would not-forking cause a problem.

because #197 (comment)

@OlegYch
Copy link

OlegYch commented Feb 23, 2020

@SethTisue so if i have a dependency like scala-compiler had i will have a problem too? i have a lib compiled again 1.0.4, should i expect it to fail running against 1.1.2?

@SethTisue
Copy link
Member

SethTisue commented Feb 23, 2020

I'm sorry, I don't know. I haven't followed the status of the different branches that closely, where and when MiMa was enabled, and so on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants