Ubuntu + scala REPL, Commands not typed on console

9.9k Views Asked by At

I am using Ubuntu 18.04 + Scala 2.11.12 (OpenJDK 64-Bit Server VM, Java 1.8.0_162).

Once I open the scala shell, I am not able to see anything that I type. It gets typed though.

Below is how it is happening when I type println("Hello, world!") at console:

$ scala 
Welcome to Scala 2.11.12 (OpenJDK 64-Bit Server VM, Java 1.8.0_162).
Type in expressions for evaluation. Or try :help.

scala> Hello, world!

scala>

Any ideas on how we can get through?

6

There are 6 best solutions below

6
On BEST ANSWER

To fix the problem in the current scala repl session run:

import sys.process._
"reset" !

To fix the problem completely removed scala and install it with dpkg (not with apt):

sudo apt-get remove scala-library scala
sudo wget www.scala-lang.org/files/archive/scala-2.11.12.deb
sudo dpkg -i scala-2.11.12.deb
0
On

This worked for me!

Ubuntu steps: 1. Go to /usr/share/sbt/bin 2. Open file "sbt" 3. Add "export TERM=xterm-color" right below "#!/bin/sh"

OS X steps: 1. Go to /usr/local/bin/ 2. Open file "sbt" 3. Add "export TERM=xterm-color" right below "#!/bin/sh"

0
On

Install SBT:

echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823
sudo apt-get update
sudo apt-get install sbt

Then Type sbt on the command prompt:enter image description here

Then Type console enter image description here

Good to go.

Test: type: printf("Hello Scala")

enter image description here

Cheers!!!

3
On

The following thing is working for me.

  1. Start sbt
  2. Open a scala console via sbt.

    ~$ sbt
        [info] Loading project definition from /home/abhay/project
        [info] Set current project to abhay (in build file:/home/abhay/)
        [warn] sbt server could not start because there's another instance of sbt running on this build.
        [warn] Running multiple instances is unsupported
        sbt:abhay> console
        [info] Starting scala interpreter...
        Welcome to Scala 2.12.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_161).
        Type in expressions for evaluation. Or try :help.
        scala> printf("Hello, Abhay!"); 
        Hello, Abhay!
        scala>
    

This is working for me for now.

I am pretty sure its some environment issue. Anyone else facing something similar?

~Abhay

1
On

scala 2.11.12 as described above throws some error before the REPL is started, which is taken care in scala 2.12.x Instead remove Scala and Install the latest scala package with dpkg

sudo apt-get remove scala-library scala
sudo wget www.scala-lang.org/files/archive/scala-2.12.8.deb
sudo dpkg -i scala-2.12.8.deb
0
On

This seems to be an issue with JLine2 being built with JDK9+, but being used on JSK8.

JLine is a Java library for handling console input.

just download and install via dpkg:

https://launchpad.net/~lokkju/+archive/ubuntu/java-compat/+build/16458066/+files/libjline2-java_2.14.6-1ubuntu1~bionicppa1_all.deb