Ubuntu + scala REPL, Commands not typed on console

允我心安 提交于 2019-12-03 14:30:07

问题


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?


回答1:


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



回答2:


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




回答3:


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



回答4:


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"




回答5:


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:

Then Type console

Good to go.

Test: type: printf("Hello Scala")

Cheers!!!



来源:https://stackoverflow.com/questions/49788781/ubuntu-scala-repl-commands-not-typed-on-console

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!