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

JLine error when attempting to run the REPL with piped input #11978

Open
deanwampler opened this issue Apr 3, 2021 · 4 comments
Open

JLine error when attempting to run the REPL with piped input #11978

deanwampler opened this issue Apr 3, 2021 · 4 comments
Assignees

Comments

@deanwampler
Copy link
Contributor

deanwampler commented Apr 3, 2021

Scala 3.0.0-RC2. A command like the following:

$ scala <<EOF
:load somestuff.scala
EOF

or trying:

$ echo ":load src/script/scala/progscala3/hierarchy/Asserts.scala" | scala

Both cause this exception:

Exception in thread "main" java.lang.IllegalStateException: Unable to create a system terminal
	at org.jline.terminal.TerminalBuilder.doBuild(TerminalBuilder.java:323)
	at org.jline.terminal.TerminalBuilder.build(TerminalBuilder.java:265)
	at dotty.tools.repl.JLineTerminal.<init>(JLineTerminal.scala:23)
	at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:123)
	at dotty.tools.repl.ReplDriver.tryRunning(ReplDriver.scala:114)
	at dotty.tools.repl.Main$.main(Main.scala:6)
	at dotty.tools.repl.Main.main(Main.scala)

This is fairly well known issue, see for example https://youtrack.jetbrains.com/issue/IDEA-183619. I attempted to use the recommended fix, setting the property -Dorg.jline.terminal.dumb=true. I did this by passing the argument -J-Dorg.jline.terminal.dumb=true to the REPL, even though this argument is not documented for the REPL in the -help output. It appeared to be ignored or do nothing. I also tried setting the environment variable JAVA_OPTS=-Dorg.jline.terminal.dumb=true before starting the REPL, but that didn't work either. Finally, I even tried setting the property inside the REPL, i.e.,

$ scala <<EOF
System.setProperty("...", "...")
:load somestuff.scala
EOF

I would expect this to be too late. It also doesn't help.

Note that in the Scala 2.13 REPL, without setting the property, you get a warning that it will default to a dumb terminal, but otherwise appears to work fine.

@griggt
Copy link
Collaborator

griggt commented Apr 3, 2021

These incantations using TERM=dumb seem to work (at least on Linux)

$ TERM=dumb scala <<EOF
:load somestuff.scala
EOF
$ echo ":load src/script/scala/progscala3/hierarchy/Asserts.scala" | TERM=dumb scala

But we should probably gracefully fall back to a dumb terminal like Scala 2 does, as was also suggested here.

@griggt griggt self-assigned this Apr 3, 2021
@deanwampler
Copy link
Contributor Author

I just noticed in #11707 that using TERM=dumb should work. I confirmed it works on MacOS, too, just now. Thanks!

@catap
Copy link

catap commented Apr 13, 2024

Interesting that without TERM=dumb it simple doesn't work on OpenBSD

@catap
Copy link

catap commented Apr 24, 2024

#19744 may fixe this

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

No branches or pull requests

3 participants