1

I'm trying to create an RStudio-like experience for Scala and spark. After figuring out how to install it properly (including Scala 2.10.5) on Win7x64, I'm facing the problem, that the version of the interpreter

scala> scala.tools.nsc.Properties.versionString
res1: String = version 2.11.8

differs from the spark-shell scala version

scala> scala.tools.nsc.Properties.versionString
res1: String = version 2.10.5

and from the scala version (cmd.exe)

C:\>scala -version
Scala code runner version 2.10.5 -- Copyright 2002-2013, LAMP,EPFL

Which causes my problems according to this answer problems when starting spark from the interpreter

scala> val sc = new SparkContext(conf)
java.lang.NoSuchMethodError: scala.
collection.immutable.HashSet$.empty()Lscala/collection/immutable/HashSet;

Question: Where do I set/configure the version the interpreter uses? Searching the global settings of the Scala IDE for "interpreter" gave no results. Seems to be something that was shipped along with the Scala IDE?

(spark 1.6.1, hadoop 2.6, Scala IDE 4.4.1, Scala 2.10.5, at least that's the way it should be)

Community
  • 1
  • 1
Boern
  • 7,233
  • 5
  • 55
  • 86

1 Answers1

1

Instead of using a specific scala REPL installation, you can always use sbt console and a build.sbt file to spin up the correct version.

If you add a build.sbt file to your main directory, Scala IDE should pick up on the version you want to be using.

~/test2$ cat build.sbt
scalaVersion := "2.11.7"
~/test2$ sbt console
[info] Set current project to test2 (in build file:/projects/9ab40ff8-31cd-4860-9cc9-ceb67d1afa39/test2/)
[info] Updating {file:/projects/9ab40ff8-31cd-4860-9cc9-ceb67d1afa39/test2/}test2...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.11.7 (OpenJDK 64-Bit Server VM, Java 1.7.0_101).
Type in expressions to have them evaluated.
Type :help for more information.

scala> :q

[success] Total time: 24 s, completed Jun 16, 2016 9:18:19 PM
~/test2$ echo 'scalaVersion := "2.10.5"' > build.sbt
~/test2$ cat build.sbt
scalaVersion := "2.10.5"
~/test2$ sbt console
[info] Set current project to test2 (in build file:/projects/9ab40ff8-31cd-4860-9cc9-ceb67d1afa39/test2/)
[info] Updating {file:/projects/9ab40ff8-31cd-4860-9cc9-ceb67d1afa39/test2/}test2...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] 'compiler-interface' not yet compiled for Scala 2.10.5. Compiling...
[info]   Compilation completed in 61.292 s
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.10.5 (OpenJDK 64-Bit Server VM, Java 1.7.0_101).
Type in expressions to have them evaluated.
Type :help for more information.

scala> :q

[success] Total time: 77 s, completed Jun 16, 2016 9:20:45 PM

You can also specify library dependencies from places like mvnrepository and sbt will download them (if not already downloaded) and add them to your REPL classpath.

As a final aside, check out Jupyter Scala for an Ipython-esque notebook interface for Scala.

evan.oman
  • 5,922
  • 22
  • 43