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

2.3.3-RC1 always crashes with "classpath is corrupted" #1628

Closed
adampauls opened this issue Jan 10, 2020 · 15 comments · Fixed by #1654
Closed

2.3.3-RC1 always crashes with "classpath is corrupted" #1628

adampauls opened this issue Jan 10, 2020 · 15 comments · Fixed by #1654
Labels

Comments

@adampauls
Copy link
Contributor

adampauls commented Jan 10, 2020

I tried upgrading to 2.3.3-RC1 and I always get

[error] scalafmt version 2.3.3-RC1 classpath is corrupted

I've tried running sbt clean update and that did not help. This issue is not present with 2.3.2 so I do not believe it is my setup.

Thanks for the great tool, looking forward to using 2.3.3!

My configuration is:

version = "2.3.3-RC1"
maxColumn = 120 
rewrite.rules = [PreferCurlyFors, SortModifiers, AvoidInfix, SortImports]
trailingCommas = always
assumeStandardLibraryStripMargin = true
optIn.breakChainOnFirstMethodDot = false
spaces.inImportCurlyBraces = true
includeCurlyBraceInSelectChains = true
spaces.beforeContextBoundColon = Always
// These are copied from  https://scalameta.org/scalafmt/docs/configuration.html#other
rewrite.neverInfix.excludeFilters = [
  until
  to
  by
  eq
  ne
  "should.*"
  "contain.*"
  "must.*"
  in
  ignore
  be
  taggedAs
  thrownBy
  synchronized
  have
  when
  size
  only
  noneOf
  oneElementOf
  noElementsOf
  atLeastOneElementOf
  atMostOneElementOf
  allElementsOf
  inOrderElementsOf
  theSameElementsAs
  // these are new
  throws
  returns
  satisfy
]
@adampauls
Copy link
Contributor Author

As a follow-up: I cleaned out my coursier cache and tried again. I also tried limiting concurrency like in #1399 and only running on a single project. None of it helped :(

@tanishiking
Copy link
Member

tanishiking commented Jan 16, 2020

@adampauls Thank you for reporting! Which version of sbt scalafmt are you using?
And could you share the stacktrace if possible?

@poslegm
Copy link
Collaborator

poslegm commented Jan 16, 2020

@tanishiking It reproduces with Intellij integration. So I guess that it is not sbt-scalafmt problem

@tanishiking
Copy link
Member

Thanks for your input!.
The error comes from scalafmt-dynamic here, and it would be nice to know which version of scalafmt-dynamic causes this problem :)

But, it might be better to emit the original error message of ReflectiveOperationException: sbt-scalafmt (v2.3.0) discards the original message of the exception, and we have no clue to tackle this problem.

@adampauls
Copy link
Contributor Author

I was using sbt-scalafmt 2.0.2. I just tried upgrading to 2.3.0 (sorry, I forgot that was an option), but that did not resolve the issue.

@kitbellew
Copy link
Collaborator

@tanishiking now that you've merged the sbt-scalafmt fix, how do we go forward with this? i don't think we can release 2.3.3 without fixing this, even though i can't reproduce it (as i don't use sbt). any way i can help?

@tanishiking
Copy link
Member

I just cut a new release of sbt-scalafmt v2.3.1, which will show an additional error message for that error.
Could you try it, and share the error message, please? @adampauls


@kitbellew
Thank you for your comments, unfortunately, that change in sbt-scalafmt doesn't fix this problem (it just enable sbt-scalafmt to emit more error messages to get more information to tackle this problem). So it may take more time to fix this.

i don't think we can release 2.3.3 without fixing this,

I think we can release 2.3.3 without fixing this :) , because

  • This problem is a long-existing issue since v2.0.0 (unfortunately)
    • scalafmt works fine for most users.
  • this is the problem of scalafmt-dynamic I guess, and the sequence of changes in scalafmt-core are nothing to do with this issue.

Anyway, I hope we can figure out the root problem of this problem...

@kitbellew
Copy link
Collaborator

@tanishiking

i don't think we can release 2.3.3 without fixing this,
I think we can release 2.3.3 without fixing this :) , because

ah, that's great to hear.

p.s. by the way, what is the process of releasing (apart from tagging a commit)?

@adampauls
Copy link
Contributor Author

I tried downloading v2.3.1 of the plugin, but I don't think it's available yet. That said, I want to make clear that the issue does seem to be specific to 2.3.3, even if the bug is in the plugin and not scalafmt itself. Every other version that I've tried works fine for me.

@kitbellew
Copy link
Collaborator

@adampauls have you tried sbt-scalafmt 2.2.1 with formatter 2.3.3-RC2? does sbt-scalafmt 2.3.0 work with formatter 2.3.2 or earlier, for you?

also, how does one specify for a given sbt-scalafmt instance which scalafmt library version should be used? is it just through the config file and dynamic loading?

@tanishiking
Copy link
Member

tanishiking commented Jan 28, 2020

Oops, sorry I misunderstood the problem. This phenomenon is reproduced even in my environment. If we try to use 2.3.3-RC1 from both sbt-scalafmt (v2.3.0) and scalafmt-cli (v2.3.2)

piece of stacktrace from cli
org.scalafmt.cli.FailedToFormat: /Users/tanishiking/dev/src/github.com/tanishiking/scalafmt/.scalafmt.conf
Caused by: java.lang.RuntimeException: scalafmt version 2.3.3-RC2 classpath is corrupted
        at org.scalafmt.interfaces.ScalafmtReporter.error(ScalafmtReporter.java:38)
        at org.scalafmt.cli.ScalafmtCliReporter.error(ScalafmtCliReporter.scala:15)
        at org.scalafmt.dynamic.ScalafmtDynamic.reportError(ScalafmtDynamic.scala:96)
        at org.scalafmt.dynamic.ScalafmtDynamic.format(ScalafmtDynamic.scala:74)
        at org.scalafmt.cli.ScalafmtDynamicRunner$.handleFile(ScalafmtDynamicRunner.scala:96)
        at org.scalafmt.cli.ScalafmtDynamicRunner$.$anonfun$run$4(ScalafmtDynamicRunner.scala:55)
        at org.scalafmt.cli.ScalafmtDynamicRunner$.$anonfun$run$4$adapted(ScalafmtDynamicRunner.scala:49)
        at scala.collection.immutable.List.foreach(List.scala:392)
        at org.scalafmt.cli.ScalafmtDynamicRunner$.$anonfun$run$3(ScalafmtDynamicRunner.scala:49)
        at scala.util.control.Breaks.breakable(Breaks.scala:42)
        at org.scalafmt.cli.ScalafmtDynamicRunner$.run(ScalafmtDynamicRunner.scala:49)
        at org.scalafmt.cli.Cli$.runWithRunner(Cli.scala:135)
        at org.scalafmt.cli.Cli$.run(Cli.scala:84)
        at org.scalafmt.cli.Cli$.mainWithOptions(Cli.scala:69)
        at org.scalafmt.cli.Cli$.main(Cli.scala:58)
        at org.scalafmt.cli.Cli.main(Cli.scala)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at coursier.bootstrap.launcher.a.a(Unknown Source)
        at coursier.bootstrap.launcher.Launcher.main(Unknown Source)
Caused by: java.lang.NoSuchMethodException: org.scalafmt.Scalafmt.format(java.lang.String, org.scalafmt.config.ScalafmtConfig, scala.collection.immutable.Set)
        at java.lang.Class.getMethod(Class.java:1786)
        at org.scalafmt.dynamic.ScalafmtReflect.<init>(ScalafmtReflect.scala:40)
        at org.scalafmt.dynamic.ScalafmtDynamic.$anonfun$resolveClassPath$1(ScalafmtDynamic.scala:188)
        at scala.util.Try$.apply(Try.scala:213)
        at org.scalafmt.dynamic.ScalafmtDynamic.resolveClassPath(ScalafmtDynamic.scala:186)
        at org.scalafmt.dynamic.ScalafmtDynamic.$anonfun$resolveFormatter$3(ScalafmtDynamic.scala:177)
        at scala.util.Either.flatMap(Either.scala:341)
        at org.scalafmt.dynamic.ScalafmtDynamic.$anonfun$resolveFormatter$1(ScalafmtDynamic.scala:177)
        at scala.util.Try$.apply(Try.scala:213)
        at org.scalafmt.dynamic.utils.ReentrantCache.getOrAddToCache(ReentrantCache.scala:41)
        at org.scalafmt.dynamic.ScalafmtDynamic.resolveFormatter(ScalafmtDynamic.scala:163)
        at org.scalafmt.dynamic.ScalafmtDynamic.$anonfun$resolveConfigWithScalafmt$2(ScalafmtDynamic.scala:142)
        at scala.util.Either.flatMap(Either.scala:341)
        at org.scalafmt.dynamic.ScalafmtDynamic.resolveConfigWithScalafmt(ScalafmtDynamic.scala:139)
        at org.scalafmt.dynamic.ScalafmtDynamic.$anonfun$resolveConfig$4(ScalafmtDynamic.scala:125)
        at scala.util.Try$.apply(Try.scala:213)
        at org.scalafmt.dynamic.utils.ReentrantCache.getOrAddToCache(ReentrantCache.scala:41)
        at org.scalafmt.dynamic.ScalafmtDynamic.resolveConfig(ScalafmtDynamic.scala:124)
        at org.scalafmt.dynamic.ScalafmtDynamic.formatDetailed(ScalafmtDynamic.scala:108)

We have to fix this before cutting a new release (2.3.3), but I'm not sure what causes this...


@adampauls
Sorry, the release process for sbt-scalafmt 2.3.1 seemed to fail... I'm gonna check it this weekend.


@kitbellew

what is the process of releasing (apart from tagging a commit)

@kitbellew
Copy link
Collaborator

@tanishiking is it possible that i "cut" the two rc releases incorrectly? i didn't do the "releases/new", simply tagged the repo as olafur once suggested.

@kitbellew
Copy link
Collaborator

@tanishiking i will fix shortly. the problem you saw is from 117477b

@poslegm
Copy link
Collaborator

poslegm commented Jan 28, 2020

@tanishiking

Sorry, the release process for sbt-scalafmt 2.3.1 seemed to fail... I'm gonna check it this weekend.

It may be related: https://issues.sonatype.org/browse/OSSRH-34782

kitbellew added a commit to kitbellew/scalafmt that referenced this issue Jan 28, 2020
Create a new, package-private method .formatCode with the implementation
based on the existing .format.

Make sure not to modify the existing interfaces of .format overloads, as
they are externally expected (via reflection).

Fixes scalameta#1628.
kitbellew added a commit to kitbellew/scalafmt that referenced this issue Jan 29, 2020
Create a new, package-private method .formatCode with the implementation
based on the existing .format.

Make sure not to modify the existing interfaces of .format overloads, as
they are externally expected (via reflection).

Fixes scalameta#1628.
kitbellew added a commit that referenced this issue Jan 29, 2020
Create a new, package-private method .formatCode with the implementation
based on the existing .format.

Make sure not to modify the existing interfaces of .format overloads, as
they are externally expected (via reflection).

Fixes #1628.
@tanishiking
Copy link
Member

@adampauls
kitbellew fixed this problem in the latest master #1654 (thank you!), so this will be fixed in the next release. Thank you for reporting!

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

Successfully merging a pull request may close this issue.

4 participants