Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ubuntu + scala REPL, Commands not typed on console

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?

like image 278
Abhay Dandekar Avatar asked Apr 12 '18 05:04

Abhay Dandekar


People also ask

How do I run a scala code in REPL?

We can start Scala REPL by typing scala command in console/terminal. Let's understand how we can add two variable using Scala REPL. In first line we initialized two variable in Scala REPL. Then Scala REPL printed these.

How do I start scala console?

To run Scala from the command-line, download the binaries and unpack the archive. Start the Scala interpreter (aka the “REPL”) by launching scala from where it was unarchived. Start the Scala compiler by launching scalac from where it was unarchived.

How do you clear the screen in scala REPL?

Implementing it wouldn't be hard, either! I believe Ctrl + L should be able to clear the REPL console.

How does scala REPL work?

The Scala REPL is a tool (scala) for evaluating expressions in Scala. The scala command will execute a source script by wrapping it in a template and then compiling and executing the resulting program.


2 Answers

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 
like image 58
mgershen Avatar answered Nov 04 '22 12:11

mgershen


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

like image 37
Abhay Dandekar Avatar answered Nov 04 '22 13:11

Abhay Dandekar