Sbt and scala has different versions?


I installed sbt by manual, and the system has scala installed by default.
I saw they have different versions.

$ scala -version

Scala code runner version 2.11.12 – Copyright 2002-2017, LAMP/EPFL

$ cat /etc/issue

Ubuntu 18.04.6 LTS \n \l

$ sbt

[info] Starting scala interpreter…

Welcome to Scala 2.12.15 (OpenJDK 64-Bit Server VM, Java 11.0.11).

Type in expressions for evaluation. Or try :help.

How do I upgrade scala to the same version as sbt?

Thanks in advance.

Sbt downloads and runs whatever version of Scala you ask it to use in the build.sbt file, e.g.,

scalaVersion := “2.13.7”

It ignores Scala on your path. I’m assuming you don’t have a build.sbt file in that directory or you didn’t specify the version of Scala. In this case, it picked the version, 2.12.15, that sbt itself is using. This version is decoupled from your project’s Scala version. SBT can run 2.12.15 while building artifacts using 2.13.7 or whatever.

1 Like