olafurpg / setup-scala

GitHub Action to install any version of Java (GraalVM, Java 8, Java 11, Java 14, ...) via Jabba. Works for any JVM language including Java, Scala and Kotlin.
MIT License
168 stars 30 forks source link

SBT 1.5.0: java.lang.NoClassDefFoundError: scala/tools/nsc/reporters/FilteringReporter #35

Closed tovbinm closed 3 years ago

tovbinm commented 3 years ago

Hello,

We just upgraded to sbt 1.5.0 and got the following error:

Exception in thread "sbt-parser-init-thread" java.lang.NoClassDefFoundError: scala/tools/nsc/reporters/FilteringReporter
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
    at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:550)
    at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:458)
    at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:452)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:451)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    at sbt.internal.parser.SbtParser$.<init>(SbtParser.scala:138)
    at sbt.internal.parser.SbtParser$.<clinit>(SbtParser.scala)
    at sbt.internal.parser.SbtParserInit$$anon$2.run(SbtParser.scala:191)
Caused by: java.lang.ClassNotFoundException: scala.tools.nsc.reporters.FilteringReporter
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    ... 13 more
[info] welcome to sbt 1.5.0 (GraalVM Community Java 11.0.9)
java.lang.NoClassDefFoundError: Could not initialize class sbt.internal.parser.SbtParser$
    at sbt.internal.parser.SbtParser.splitExpressions(SbtParser.scala:247)
    at sbt.internal.parser.SbtParser.<init>(SbtParser.scala:236)
    at sbt.internal.EvaluateConfigurations$.splitExpressions(EvaluateConfigurations.scala:289)
    at sbt.internal.EvaluateConfigurations$.parseConfiguration(EvaluateConfigurations.scala:98)
    at sbt.internal.EvaluateConfigurations$.evaluateSbtFile(EvaluateConfigurations.scala:147)
    at sbt.internal.Load$.loadSettingsFile$1(Load.scala:1107)
    at sbt.internal.Load$.$anonfun$discoverProjects$2(Load.scala:1117)
    at scala.collection.MapLike.getOrElse(MapLike.scala:131)
    at scala.collection.MapLike.getOrElse$(MapLike.scala:129)
    at scala.collection.AbstractMap.getOrElse(Map.scala:65)
    at sbt.internal.Load$.memoLoadSettingsFile$1(Load.scala:1116)
    at sbt.internal.Load$.$anonfun$discoverProjects$4(Load.scala:1124)
    at scala.collection.immutable.List.map(List.scala:293)
    at sbt.State$StateOpsImpl$.runCmd$1(State.scala:289)
    at sbt.State$StateOpsImpl$.process$extension(State.scala:325)
    at sbt.MainLoop$.$anonfun$next$4(MainLoop.scala:163)
    at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
    at sbt.MainLoop$.next(MainLoop.scala:163)
    at sbt.MainLoop$.run(MainLoop.scala:144)
    at sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:119)
    at sbt.io.Using.apply(Using.scala:27)
    at sbt.MainLoop$.runWithNewLog(MainLoop.scala:112)
    at sbt.MainLoop$.runAndClearLast(MainLoop.scala:66)
    at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:51)
    at sbt.MainLoop$.runLogged(MainLoop.scala:42)
    at sbt.StandardMain$.runManaged(Main.scala:192)
    at sbt.xMain$.$anonfun$run$8(Main.scala:101)
    at sbt.internal.util.Terminal$.withStreams(Terminal.scala:381)
    at sbt.xMain$.run(Main.scala:86)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at sbt.internal.XMainConfiguration.run(XMainConfiguration.java:56)
    at sbt.xMain.run(Main.scala:46)
    at coursier.sbtlauncher.LauncherApp$.$anonfun$doRun$4(LauncherApp.scala:263)
    at scala.util.Either.fold(Either.scala:191)
    at coursier.sbtlauncher.LauncherApp$.doRun(LauncherApp.scala:263)
    at coursier.sbtlauncher.LauncherApp$.run(LauncherApp.scala:445)
    at coursier.sbtlauncher.LauncherApp$.run(LauncherApp.scala:16)
    at caseapp.core.app.CaseApp.main(CaseApp.scala:82)
    at coursier.sbtlauncher.MainApp$.main(MainApp.scala:81)
    at coursier.sbtlauncher.MainApp.main(MainApp.scala)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at coursier.bootstrap.launcher.a.a(Unknown Source)
    at coursier.bootstrap.launcher.Launcher.main(Unknown Source)

Are there any recommendations on how to overcome this issue?

SethTisue commented 3 years ago

presumably an out of date sbt launch script

olafurpg commented 3 years ago

The script is sbt-extras, which is installed like this

https://github.com/olafurpg/setup-scala/blob/05b368ddd620abc33fd3412cb2b33b54868a78b5/src/install.ts#L109

It's probably worth changing that to use cs install sbt instead 🤔

SethTisue commented 3 years ago

I don't trust cs install sbt. I'm optimistic it will eventually be suitable, but IMO it currently isn't, as per coursier/coursier#1957, coursier/coursier#1696, coursier/coursier#1755, coursier/coursier#1867

laughedelic commented 3 years ago

Also https://github.com/coursier/sbt-runner/issues/6.

olafurpg commented 3 years ago

What is the recommended alternative to sbt-extras?

SethTisue commented 3 years ago

What is the recommended alternative to sbt-extras?

the sbt launch script published by the sbt maintainers and included in the sbt downloads

SethTisue commented 3 years ago

@eed3si9n the recommended way to obtain that is by extracting it from e.g. https://github.com/sbt/sbt/releases/download/v1.5.0/sbt-1.5.0.tgz , yes?

(I think sometimes people go for sbt-extras just because you can easily grab the launch script by itself)

laughedelic commented 3 years ago

By the way, official sbt launcher is preinstalled in GHA runners, at least on linux and windows, not sure why not on macos.

eed3si9n commented 3 years ago

@SethTisue I think so, or SDKMAN distribution, which we garden.

I've been actually thinking the official should have an option to work in one-file Bash script way.

liufengyun commented 3 years ago

I also ran into this problem, re-install solves the problem:

cs uninstall sbt
cs install sbt
Miuler commented 3 years ago

I also ran into this problem, re-install solves the problem:

cs uninstall sbt
cs install sbt

Esto funciono para mi. This worked for me.

SethTisue commented 3 years ago

I've been actually thinking the official should have an option to work in one-file Bash script way.

Note that Eugene has now done this; the official launch script is available from e.g. https://raw.githubusercontent.com/sbt/sbt/v1.5.2/sbt

olafurpg commented 3 years ago

Thank you for reporting! Closing this since it's not clear how to address this issue in this project. Please reopen if I'm misunderstanding