Skip to content

JLine fails when running console the second time in sbt #702

@lrytz

Description

@lrytz

On my macOS

$> ls -al
total 0

$> mkdir project && echo sbt.version=1.3.8 > project/build.properties

$> cat <<EOF > log.properties
handlers=java.util.logging.ConsoleHandler
org.jline.level=FINEST
EOF

$> sbt -Djava.util.logging.config.file=log.properties 'set logLevel := Level.Debug' 'set resolvers += "scala-integration" at "https://scala-ci.typesafe.com/artifactory/scala-integration"' 'set scalaVersion := "2.13.2-bin-bc1cad4"' shell
...
sbt:a> console
[debug] Copy resource mappings:
[debug]
[debug] "not up to date. inChanged = true, force = false
[debug] Updating ...
[debug] Done updating
[debug] Full compilation, no sources in previous analysis.
[debug] Waiting for threads to exit or System.exit to be called.
[debug] Getting org.scala-sbt:compiler-bridge_2.13:1.3.4:compile for Scala 2.13.2-bin-bc1cad4
[debug] Waiting for thread run-main-0 to terminate.
[debug] Getting org.scala-sbt:compiler-bridge_2.13:1.3.4:compile for Scala 2.13.2-bin-bc1cad4
[info] Starting scala interpreter...
Welcome to Scala 2.13.2-bin-bc1cad4 (Java HotSpot(TM) 64-Bit GraalVM EE 19.2.1, Java 1.8.0_231).
Type in expressions for evaluation. Or try :help.

scala> :q
[debug] 	Thread run-main-0 exited.
[debug] Interrupting remaining threads (should be all daemons).
[debug] Interrupting thread JLine Shutdown Hook
[debug] 	Interrupted JLine Shutdown Hook
[debug] Interrupting thread Timer-0
[debug] 	Interrupted Timer-0
[debug] Sandboxed run complete..
[debug] Exited with code 0

[success] Total time: 6 s, completed Mar 26, 2020 11:56:32 AM
sbt:a> console
[debug] Copy resource mappings:
[debug]
[debug] Full compilation, no sources in previous analysis.
[debug] Waiting for threads to exit or System.exit to be called.
[debug] Getting org.scala-sbt:compiler-bridge_2.13:1.3.4:compile for Scala 2.13.2-bin-bc1cad4
[debug] Waiting for thread run-main-1 to terminate.
[debug] Getting org.scala-sbt:compiler-bridge_2.13:1.3.4:compile for Scala 2.13.2-bin-bc1cad4
[info] Starting scala interpreter...
Welcome to Scala 2.13.2-bin-bc1cad4 (Java HotSpot(TM) 64-Bit GraalVM EE 19.2.1, Java 1.8.0_231).
Type in expressions for evaluation. Or try :help.
Mar 26, 2020 11:56:34 AM org.jline.utils.Log logr
WARNING: Creating a dumb terminal
java.lang.IllegalStateException: Unable to create a system terminal
	at org.jline.terminal.TerminalBuilder.doBuild(TerminalBuilder.java:317)
	at org.jline.terminal.TerminalBuilder.build(TerminalBuilder.java:263)
	at scala.tools.nsc.interpreter.jline.Reader$.apply(Reader.scala:57)
	at scala.tools.nsc.interpreter.shell.ILoop.defaultIn$lzycompute(ILoop.scala:67)
	at scala.tools.nsc.interpreter.shell.ILoop.defaultIn(ILoop.scala:62)
	at scala.tools.nsc.interpreter.shell.ILoop.run(ILoop.scala:938)
	at xsbt.ConsoleInterface.run(ConsoleInterface.scala:78)
	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 sbt.internal.inc.AnalyzingCompiler.call(AnalyzingCompiler.scala:248)
	at sbt.internal.inc.AnalyzingCompiler.console(AnalyzingCompiler.scala:210)
	at sbt.Console.console0$1(Console.scala:48)
	at sbt.Console.$anonfun$apply$2(Console.scala:51)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
	at sbt.util.InterfaceUtil$$anon$1.get(InterfaceUtil.scala:10)
	at sbt.TrapExit$App.run(TrapExit.scala:257)
	at java.lang.Thread.run(Thread.java:748)
	Suppressed: java.lang.IllegalStateException: A system terminal is already running. Make sure to use the created system Terminal on the LineReaderBuilder if you're using one or that previously created system Terminals have been correctly closed.
		at org.jline.terminal.TerminalBuilder.doBuild(TerminalBuilder.java:397)
		... 18 more


scala>

At this point I cannot type anymore, the only thing that seems to do anything at all is ctrl-c. The sbt shell continues working.

scala>
[warn] Canceling execution...
[warn] Run canceled.
[debug] Interrupting thread run-main-1
[debug] 	Interrupted run-main-1
[debug] Interrupting thread JLine terminal non blocking reader thread
[debug] 	Interrupted JLine terminal non blocking reader thread
[error] Total time: 65 s (01:05), completed Mar 26, 2020 11:57:39 AM
sbt:a> comp
compile                   compile:                  compileAnalysisFilename   compileBinaryFileInputs   compileIncSetup           compileIncremental
compileOutputs            compileSourceFileInputs   compilers                 completions

Metadata

Metadata

Assignees

Labels

blockert:replJLine 3 upgrade (scala/scala#8036)

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions