Unable to get into repl via sbt console

I get this error when trying to get into repl via sbt console.

Failed to initialize compiler: NoClassDefFoundError.
This is most often remedied by a full clean and recompile.
Otherwise, your classpath may continue bytecode compiled by
different and incompatible versions of scala.

java.lang.NoClassDefFoundError: org/fusesource/jansi/AnsiOutputStream
	at jline.internal.Ansi.stripAnsi(Ansi.java:29)
	at jline.console.ConsoleReader.setPrompt(ConsoleReader.java:528)
	at jline.console.ConsoleReader.readLine(ConsoleReader.java:2454)
	at jline.console.ConsoleReader.readLine(ConsoleReader.java:2407)
	at jline.console.ConsoleReader.readLine(ConsoleReader.java:2395)
	at scala.tools.nsc.interpreter.jline.InteractiveReader.readOneLine(JLineReader.scala:63)
	at scala.tools.nsc.interpreter.InteractiveReader.readLine(InteractiveReader.scala:45)
	at scala.tools.nsc.interpreter.InteractiveReader.readLine$(InteractiveReader.scala:42)
	at scala.tools.nsc.interpreter.jline.InteractiveReader.readLine(JLineReader.scala:31)
	at scala.tools.nsc.interpreter.ILoop.readOneLine(ILoop.scala:473)
	at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:485)
	at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:1077)
	at xsbt.ConsoleBridge.run(ConsoleBridge.scala:75)
	at sbt.internal.inc.AnalyzingCompiler.console(AnalyzingCompiler.scala:209)
	at sbt.Console.console0$1(Console.scala:64)
	at sbt.Console.$anonfun$apply$5(Console.scala:73)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
	at sbt.util.InterfaceUtil$$anon$1.get(InterfaceUtil.scala:17)
	at sbt.TrapExit$App.run(TrapExit.scala:258)
	at java.base/java.lang.Thread.run(Thread.java:834)

I did a sbt clean. That didn’t solve the problem. sbt compile works perfectly fine and so does test.

Perhaps deleting your target folder will help. A more drastic option is to delete your coursier/ivy cache.


removing target did not help

deleting .coursier and .ivy2 didn’t help either

Have you tried consoleQuick (starts the repl without your stuff on classpath)?

yep, gives the same error

Have you tried a new sbt project with “Hello World” in a new folder to test your installation? (I suspect it has to do with non-binary compatible code running, differently versioned JVM-instances or something similar)

did not try this. Updating sbt from 1.4.8 to 1.4.9 worked

nice that you got it working! BTW: sbt 1.5.0 is out now Release 1.5.0 · sbt/sbt · GitHub

1 Like