Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sbt is using wrong scala version rather than using the configuration in build.sbt

Tags:

scala

sbt

I have put these in the build.sbt file under current project's root directory

scalaHome := Some(file("/Users/ddam/scala-2.10.2"))

scalaVersion := "2.10.2"

And I ran sbt using

$ sbt --version
sbt launcher version 0.12.4

But still, I am seeing both the wrong version for sbt and scala when a particular dependency cannot be resolved

[warn]  Note: Some unresolved dependencies have extra attributes.  Check that these dependencies exist with the requested attributes.
[warn]      com.typesafe.sbteclipse:sbteclipse-plugin:2.4.0 (sbtVersion=0.12, scalaVersion=2.9.2)

Please help me.

like image 658
Dick Avatar asked Nov 07 '13 06:11

Dick


People also ask

Which Scala version does sbt use?

sbt's Scala version 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.

How do I change the Scala version in Intellij?

In most cases your project JDK is not compatible with Scala or sbt version, try to change the Scala Compile Server SDK. Press Ctrl+Alt+S to open Settings/Preferences dialog. From the options on the left, select Build, Execution, Deployment | Compiler | Scala | Scala Compiler Server.

What is the difference between sbt and Scala?

SBT is tied to a specific project defined by a build. sbt file in a way that $ sbt console will load up the same REPL environment as $ scala but with the addition of all of the project code and dependencies defined in the build available for import. Also, it will use the version of Scala defined by build.

How do I know sbt version installed?

Ensure sbt and Scala versions compatibility Create or open your sbt project. In the Project tool window, in the source root directory, locate the build. properties file and open it in the editor. In the editor explicitly specify the version of sbt that you want to use in the project.


1 Answers

It looks like sbteclipse requires SBT 0.13.0, and you are using version 0.12.4. You can specify the SBT version by following the directions on this page.

Some other notes: You probably want to use Scala 2.10.3, not 2.10.2.

Also, it's strange to specify scalaHome; usually SBT will automatically fetch the needed Scala jars for you. So to bootstrap a Scala environment, all you need to have installed are SBT and a JDK.

EDIT: (addressing comment below): When you build code with SBT, you may actually use two different versions of Scala. There is the version for SBT (what version of Scala the build system runs on), and the version for the code in your project (what version of Scala your code will run on).

The Scala version for SBT is determined by the SBT version you use. If you use 0.12.4, SBT will run on Scala 2.9.3. If you use 0.13.0, SBT will run on Scala 2.10.3. You control the SBT version by following these instructions.

To control the version of Scala your project will run on, you can set scalaVersion in <projectRoot>/build.sbt.

So, you're getting that error because you're using SBT 0.12.4, which uses Scala 2.9.3. SBT tries to find the sbteclipse plugin for 2.9.3, but it doesn't exist because it requires SBT 0.13.0 (=> Scala 2.10.3).

like image 81
emchristiansen Avatar answered Sep 29 '22 08:09

emchristiansen