Ubuntu 18.04下Scala 2.11.12 REPL输入无回显问题求助
I’ve run into this exact quirk before with older Scala versions on Ubuntu—it’s almost always tied to terminal compatibility issues with JLine, the library Scala uses for interactive shell input. Here are a few straightforward fixes to try, ordered by how quick they are to implement:
1. Force JLine to Use the Unix Terminal
Start the Scala shell with this command to explicitly tell JLine to use the Unix terminal implementation, which bypasses auto-detection glitches that often cause invisible input:
scala -J-Djline.terminal=unix
This should immediately make your typed commands visible while you enter them.
2. Check Your TERM Environment Variable
An incorrectly set TERM variable can mess up how Scala renders input in the console. First, check your current setting:
echo $TERM
If it’s set to something odd like dumb or an unrecognized value, try switching to a standard terminal type before launching Scala:
export TERM=xterm scala
Or for 256-color terminal support:
export TERM=xterm-256color scala
3. Wrap Scala with rlwrap
If the above fixes don’t work, rlwrap is a handy tool that adds readline functionality to commands that lack it natively. Install it first:
sudo apt update && sudo apt install rlwrap
Then launch Scala using rlwrap:
rlwrap scala
This will not only make your input visible but also add useful extras like command history navigation.
4. Upgrade Scala (If Your Project Allows It)
Scala 2.11.12 is quite outdated (released in 2018), and newer versions (like 2.12.x or 2.13.x) have improved terminal compatibility. If your project can tolerate an upgrade, moving to a more recent Scala version will likely resolve this issue permanently, along with other bug fixes.
After trying any of these methods, you should see your typed commands (like println("Hello, world!")) appear in the console as you enter them.
内容的提问来源于stack exchange,提问作者Abhay Dandekar

