Tuesday, March 15, 2022

[SOLVED] sbt fails with java.lang.NoClassDefFoundError: sbt/ConsoleOut$

Issue

After using sbt for some time, something failed and I can't run sbt on my Ubuntu machine. I get this exception no matter what I do. Even running sbt help causes the following error:

java.lang.NoClassDefFoundError: sbt/ConsoleOut$
    at sbt.StandardMain$.<init>(Main.scala:52)
    at sbt.StandardMain$.<clinit>(Main.scala)
    at sbt.xMain.run(Main.scala:26)
    at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:57)
    at xsbt.boot.Launch$.withContextLoader(Launch.scala:77)
    at xsbt.boot.Launch$.run(Launch.scala:57)
    at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:45)
    at xsbt.boot.Launch$.launch(Launch.scala:65)
    at xsbt.boot.Launch$.apply(Launch.scala:16)
    at xsbt.boot.Boot$.runImpl(Boot.scala:32)
    at xsbt.boot.Boot$.main(Boot.scala:21)
    at xsbt.boot.Boot.main(Boot.scala)
Caused by: java.lang.ClassNotFoundException: sbt.ConsoleOut$
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 12 more
Error during sbt execution: java.lang.NoClassDefFoundError: sbt/ConsoleOut$

I reinstalled the JDK and of course sbt, but it didn't help. The only thing I remember doing was installing the new IntelliJ IDEA 13. Could this be related?


Solution

the only thing I remember doing was installing the new intellij (v13). Is this related?

It could be related.

Try:

rm -rf ~/.ivy/cache
mv ~/.sbt ~/.sbt.old


Answered By - Robin Green
Answer Checked By - Senaida (WPSolving Volunteer)