Ubuntu + scala REPL,命令未在控制台上输入

时间:2018-04-12 05:38:54

标签: scala ubuntu scala-repl

我正在使用Ubuntu 18.04 + Scala 2.11.12(OpenJDK 64位服务器VM,Java 1.8.0_162)。

一旦我打开scala shell,我就无法看到我键入的任何内容。它虽然打字了。

以下是我在主机上输入 println("Hello, world!") 时的情况:

$ 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>

关于我们如何通过的任何想法?

6 个答案:

答案 0 :(得分:42)

要解决当前scala repl会话中的问题,请执行以下操作:

import sys.process._
"reset" !

要解决此问题,请完全删除scala并使用dpkg(而不是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

答案 1 :(得分:14)

以下事情对我有用。

  1. 启动sbt
  2. 通过sbt。

    打开一个scala控制台
    ~$ 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>
    
  3. 这对我现在很有用。

    我很确定它存在一些环境问题。其他人面对类似的东西?

    〜阿沛

答案 2 :(得分:1)

这对我有用!

Ubuntu步骤: 1.转到/ usr / share / sbt / bin 2.打开文件“ sbt” 3.在“#!/ bin / sh”正下方添加“ export TERM = xterm-color”

OS X步骤: 1.转到/ usr / local / bin / 2.打开文件“ sbt” 3.在“#!/ bin / sh”正下方添加“ export TERM = xterm-color”

答案 3 :(得分:1)

如上所述,

scala 2.11.12在启动REPL之前会引发一些错误,这在scala 2.12.x中已得到解决,而是删除Scala并使用dpkg安装最新的scala软件包

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 :(得分:0)

这似乎是JLine2用JDK9 +构建的问题,但是在JSK8上使用。

JLine 是用于处理控制台输入的Java库。

只需通过dpkg下载并安装:

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

答案 5 :(得分:-1)

安装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

然后在命令提示符下键入 sbt enter image description here

然后输入控制台 enter image description here

很好。

测试: 类型:printf(“ Hello Scala”)

enter image description here

干杯!

相关问题