Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scala is 2.10.1 but sbt console is not?

Tags:

scala

sbt

I'm new to Scala/SBT, so please be gentle, but I'm trying to work my way through the SBT "Getting Started" and I noticed a discrepancy between my brew installed scala and sbt tools. When I launch the REPL for scala directly, it reports itself as Scala 2.10.1, which is what I would expect.

bobk-mbp:work bobk$ scala
Welcome to Scala version 2.10.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_17).
Type in expressions to have them evaluated.
Type :help for more information.

scala> :quit

When I launch the REPL through SBT, the REPL asserts it is 2.9.2?!?

bobk-mbp:work bobk$ sbt console
[info] Set current project to default-690573 (in build file:/Users/bobk/work/)
[info] Starting scala interpreter...
[info] 
Welcome to Scala version 2.9.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_17).
Type in expressions to have them evaluated.
Type :help for more information.

scala> :quit

What's up with that? I was expecting the build tool to use the scala environment that is hosted on my dev box. Where is it getting 2.9.2 and how do I get it to use the 2.10.1?

Both scala and sbt were installed via brew, but I don't think that really matters. The sbt version appears to be 0.12.3

bobk-mbp:work bobk$ sbt --version
sbt launcher version 0.12.3
like image 469
Bob Kuhar Avatar asked May 06 '13 20:05

Bob Kuhar


People also ask

Which Scala version does sbt use?

sbt uses that same version of Scala to compile the build definitions that you write for your project because they use sbt APIs. This version of Scala is fixed for a specific sbt release and cannot be changed. For sbt 1.7. 1, this version is Scala 2.12.

Is sbt same as Scala?

sbt is an open source build tool for Scala and Java projects, similar to Java's Maven or Ant. Its main features are: native support for compiling Scala code, and integration with many Scala test frameworks.

Do I need sbt for Scala?

sbt is a popular tool for compiling, running, and testing Scala projects of any size. Using a build tool such as sbt (or Maven/Gradle) becomes essential once you create projects with dependencies or more than one code file.


2 Answers

Sbt downloads the scala doesnt need to have an installed one.

If you want to define something global use the ~/.sbt/global.sbt

In global.sbt you can insert scalaVersion := "2.10.1" and if you want to use your local installed version also define scalaHome := Some(file("/home/iraklis/apps/scala-2.10.1"))

For more detail visit sbt documentation (link)

like image 115
Iraklis Avatar answered Oct 27 '22 02:10

Iraklis


If you start sbt with no parameters:

sbt
> ++ 2.10.1
> console

should give you Scala 2.10.1 for that session. I don't know how to make it the default for all sbt sessions without rebuilding sbt itself.

like image 24
trenobus Avatar answered Oct 27 '22 02:10

trenobus