Skip to content
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

java.lang.NoSuchMethodError: fastparse.all$.CharsWhileIn$default$2()I #1200

Closed
fommil opened this issue May 29, 2018 · 19 comments
Closed

java.lang.NoSuchMethodError: fastparse.all$.CharsWhileIn$default$2()I #1200

fommil opened this issue May 29, 2018 · 19 comments
Milestone

Comments

@fommil
Copy link

fommil commented May 29, 2018

in 1.6.0-RC1 I'm getting this...

I figure this is a configuration / dependency version problem that can probably be eyeballed and creating a minimisation would be a lot of work for little benefit.

> fmt
[error] java.lang.NoSuchMethodError: fastparse.all$.CharsWhileIn$default$2()I
[error] 	at scala.meta.internal.tokenizers.XmlParser.<init>(XmlParser.scala:16)
[error] 	at scala.meta.internal.tokenizers.LegacyScanner.getXml(LegacyScanner.scala:990)
[error] 	at scala.meta.internal.tokenizers.LegacyScanner.fetchLT$1(LegacyScanner.scala:347)
[error] 	at scala.meta.internal.tokenizers.LegacyScanner.fetchToken(LegacyScanner.scala:355)
[error] 	at scala.meta.internal.tokenizers.LegacyScanner.nextToken(LegacyScanner.scala:241)
[error] 	at scala.meta.internal.tokenizers.LegacyScanner.foreach(LegacyScanner.scala:1068)
[error] 	at scala.meta.internal.tokenizers.ScalametaTokenizer.uncachedTokenize(ScalametaTokenizer.scala:153)
[error] 	at scala.meta.internal.tokenizers.ScalametaTokenizer.tokenize(ScalametaTokenizer.scala:31)
[error] 	at scala.meta.internal.tokenizers.ScalametaTokenizer$$anon$2.apply(ScalametaTokenizer.scala:287)
[error] 	at scala.meta.tokenizers.Api$XtensionTokenizeDialectInput.tokenize(Api.scala:21)
[error] 	at scala.meta.tokenizers.Api$XtensionTokenizeInputLike.tokenize(Api.scala:10)
[error] 	at scala.meta.internal.parsers.ScalametaParser.scannerTokens$lzycompute(ScalametaParser.scala:183)
[error] 	at scala.meta.internal.parsers.ScalametaParser.scannerTokens(ScalametaParser.scala:183)
[error] 	at scala.meta.internal.parsers.ScalametaParser.<init>(ScalametaParser.scala:140)
[error] 	at scala.meta.internal.parsers.ScalametaParser$$anon$189.apply(ScalametaParser.scala:3462)
[error] 	at scala.meta.parsers.Api$XtensionParseDialectInput.parse(Api.scala:21)
[error] 	at org.scalafmt.rewrite.Rewrite$.apply(Rewrite.scala:78)
[error] 	at org.scalafmt.Scalafmt$.format(Scalafmt.scala:50)
[error] 	at org.scalafmt.Scalafmt$.format(Scalafmt.scala:82)
[error] 	at org.scalafmt.sbt.ScalafmtPlugin$.$anonfun$withFormattedSources$2(ScalafmtPlugin.scala:73)
[error] 	at scala.collection.TraversableLike$WithFilter.$anonfun$map$2(TraversableLike.scala:739)
[error] 	at scala.collection.mutable.ResizableArray.foreach(ResizableArray.scala:59)
[error] 	at scala.collection.mutable.ResizableArray.foreach$(ResizableArray.scala:52)
[error] 	at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
[error] 	at scala.collection.TraversableLike$WithFilter.map(TraversableLike.scala:738)
[error] 	at org.scalafmt.sbt.ScalafmtPlugin$.withFormattedSources(ScalafmtPlugin.scala:70)
[error] 	at org.scalafmt.sbt.ScalafmtPlugin$.formatSources(ScalafmtPlugin.scala:105)
[error] 	at org.scalafmt.sbt.ScalafmtPlugin$.$anonfun$scalafmtConfigSettings$3(ScalafmtPlugin.scala:174)
[error] 	at org.scalafmt.sbt.ScalafmtPlugin$.$anonfun$scalafmtConfigSettings$3$adapted(ScalafmtPlugin.scala:165)
@olafurpg
Copy link
Member

Thanks for reporting! Can you check what version of fastparse is in your sbt classpath? Scalameta and scalafmt are on fastparse v1.0.0, which is the latest release. If another plugin is bringing in fastparse v0.4.2 or older then this might be causing problems.

@fommil
Copy link
Author

fommil commented May 29, 2018

oh joy (using ensime to generate a build definition file to debug this...)

 "/home/fommil/.sbt/boot/scala-2.12.6/org.scala-sbt/sbt/1.1.5/fastparse-utils_2.12-0.4.2.jar" "/home/fommil/.coursier/cache/v1/https/repo1.maven.org/maven2/com/lihaoyi/fastparse-utils_2.12/1.0.0/fastparse-utils_2.12-1.0.0.jar"

looks like sbt itself depends on fastparse. And it is not shading it...

@olafurpg
Copy link
Member

Looks like zinc needs to update it's ScalaPB dependency, in sbt/zinc

$ rg scalapb
project/plugins.sbt
6:libraryDependencies += "com.trueaccord.scalapb" %% "compilerplugin" % "0.6.0"

Reported in sbt/zinc#546

@fommil
Copy link
Author

fommil commented May 29, 2018

I guess there will be no scalafmt or scalafix in sbt for a while then...

@olafurpg
Copy link
Member

Not sure if this works, but worth a try in project/plugins.sbt

dependencyOverrides += "com.lihaoyi" %% "fastparse" % "1.0.0"

@olafurpg
Copy link
Member

ScalaPB uses fastparse to parse text format protobuf messages, which zinc does not use so this should be safe

@fommil
Copy link
Author

fommil commented May 29, 2018

that doesn't work because the groupId is wrong... it's renamed to org.scala-sbt. Could try an exclusion filter.

But since it's the boot jars, that might not work either...

@olafurpg
Copy link
Member

Ticket moved to scalameta/scalameta#1573 seems better to fix it on our front instead of waiting for sbt 2.

@tksfz
Copy link

tksfz commented May 31, 2018

Is there a short-term work-around for this?

@fommil
Copy link
Author

fommil commented May 31, 2018

I've been trying to convince @olafurpg to just shade or fork fastparse 😛

@olafurpg
Copy link
Member

olafurpg commented May 31, 2018 via email

@tksfz
Copy link

tksfz commented May 31, 2018

I ended up just excluding the problematic source file

@fommil
Copy link
Author

fommil commented May 31, 2018

or just downgrade your version to that used by sbt...

@olafurpg
Copy link
Member

Besides the migration cost to downgrade, that would be a breaking change force all scalameta users on a ~2 year old dependency of fastparse.

@fommil
Copy link
Author

fommil commented May 31, 2018

scalameta users should all be scala tooling authors, who'll almost certainly have to deal with the sbt storm anyway...

@olafurpg
Copy link
Member

I've been convinced that it is a good idea to shade sbt-scalafmt dependencies to avoid binary conflicts with sbt/zinc and other sbt plugins.

@olafurpg
Copy link
Member

Just merged #1218 where I added a new module scalafmt-big that is a fat jar with shaded dependencies. The PR also removes the sbt-scalafmt plugin, which will live in a separate repo from now on. Will create scalameta/sbt-scalaft repo now.

@olafurpg
Copy link
Member

sbt-scalafmt v1.6.0-RC3 is out with a shaded version of fastparse and scalameta. Please let me know if this issue has been resolved :)

@olafurpg
Copy link
Member

Got a confirmation in #1218 (comment) that this issue has been fixed. Please reopen if you encounter binary incompatibilities in sbt!

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

3 participants