1

When I install the latest version of sbt (v0.13.9) and then run the following to download scala and associated libraries:

jdoe$ sbt test
jdoe$
jdoe$ sbt console
[info] Set current project to nmvega (in build file:/home/jdoe/)
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.10.5 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_31).
Type in expressions to have them evaluated.
Type :help for more information.

scala>

I get Scala version 2.10.5, as seen above.

How can I get sbt to build with (or use a separately installed) scala version, say v2.12.0-M3 ? I can't find instructions for this.

Thank you in advance.

NYCeyes
  • 5,215
  • 6
  • 57
  • 64
  • 2
    Possible duplicate of [How to change Scala version for sbt project?](http://stackoverflow.com/questions/2888031/how-to-change-scala-version-for-sbt-project) – Daenyth Dec 14 '15 at 19:54
  • 1
    Duplicate of [scala is 2.10.1 but sbt console is not?](http://stackoverflow.com/questions/16407042/scala-is-2-10-1-but-sbt-console-is-not) – Yuriy Tumakha Dec 14 '15 at 20:10

2 Answers2

2

Can you post your build.sbt please.

You should be able to declare the Scala by adding the following to build.sbt file

scalaVersion := "2.11.7"
toidiu
  • 965
  • 2
  • 12
  • 25
2

As you can see in documentation SBT provides many ways to Configure and use Scala

Set the Scala version used for building the project

The scalaVersion configures the version of Scala used for compilation. By default, sbt also adds a dependency on the Scala library with this version. See the next section for how to disable this automatic dependency. If the Scala version is not specified, the version sbt was built against is used. It is recommended to explicitly specify the version of Scala.

For example, to set the Scala version to "2.9.2",

scalaVersion := "2.9.2"

Disable the automatic dependency on the Scala library

sbt adds a dependency on the Scala standard library by default. To disable this behavior, set the autoScalaLibrary setting to false.

autoScalaLibrary := false

Temporarily switch to a different Scala version

To set the Scala version in all scopes to a specific value, use the ++ command. For example, to temporarily use Scala 2.8.2, run:

> ++ 2.8.2

Use a local Scala installation for building a project

Defining the scalaHome setting with the path to the Scala home directory will use that Scala installation. sbt still requires scalaVersion to be set when a local Scala version is used. For example,

scalaVersion := "2.10.0-local"
scalaHome := Some(file("/path/to/scala/home/"))
Yuriy Tumakha
  • 1,450
  • 17
  • 21
  • Ah thank you Yuriy for pointing me to that direct v0.13.5 URL. I could not find the same under v0.13.9. – NYCeyes Dec 14 '15 at 20:33
  • 1
    You are welcome. By the way page is also available for the latest SBT http://www.scala-sbt.org/0.13/docs/Howto-Scala.html – Yuriy Tumakha Dec 14 '15 at 20:41
  • Awesome (bookmarked). I see what my issue was (or were; a combination of things). I'm following a book (I'm new to Scala) and didn't realize the author was issuing the "sbt test" command from inside his git cloned directory (for the book). So I didn't even have a "build.sbt". =:) Then, looking at your collective replies, I realized I was missing something, and it dawned on me. Thanks again. – NYCeyes Dec 14 '15 at 21:09