I get this warning when running sbt ensimeConfig on my project directory
You have a different version of scala for ENSIME (2.10.6) and webapp (2.11.8)
How can I change the version of Ensime to 2.11.8 globally?
Related
I need to run a sbt plugin compiled for scala 2.11.
However, sbt tries to download the plugin for scala 2.12. How I force sbt to use scala 2.11?
ps: adding scalaVersion := "2.11.11" to build.sbt does not solve the problem, as the sbt plugin is not affected by this.
You cannot choose what Scala runtime is the SBT built against, you need to use the version compatible with the SBT you have. The only choice you have is which SBT version you use. See also How to change Scala version for build definition?
Sbt 1.x.x requires you to use Java 8 and Scala 2.12 - see SBT 1.0.0
sbt 1.0 uses Scala 2.12 for build definitions and plugins. This also requires JDK 8.
Previous 0.13 versions used Scala 2.10, see 0.13.1 notes:
The Scala version for sbt and sbt plugins is now 2.10.3.
There is no version using 2.11.x
I'm trying to get Scala set up for a Coursera course on Ubuntu, and I've followed their instructions by installing open-jdk 1.8, sbt (sbt about says v1.0.2), and IntelliJ Idea. I've set up an sbt project with a HelloWorld Scala worksheet in src/main/scala that just says "Hello, world", but when I try to evaluate the worksheet, I get the error
Internal error: Scala instance doesn't exist or is invalid: version unknown, library jar: /home/[my username]/.ivy2/cache/jline/jline/jars/jline-2.14.5.jar, compiler jar: /home/[my username]/.ivy2/cache/org.scala-lang.modules/scala-xml_2.12/bundles/scala-xml_2.12-1.0.6.jar
followed by a longer trace. Is there a setup step I'm missing? The project seems to point to Java v1.8 in the Project Structure dependencies, and in the "Libraries" tab I see SBT set to Scala v2.12.
I've just had the same problem with macOS Sierra.
I solved after noticing that in my build.sbt I had:
name := "myScalaTests"
version := "0.1"
scalaVersion := "2.12.4"
but prompting sbt about, my scala version was different.
sbt about
[warn] No sbt.version set in project/build.properties, base directory: /Users/myUser/projects
[info] Set current project to projects (in build file:/Users/myUser/projects/)
[info] This is sbt 1.0.2
[info] The current project is {file:/Users/myUser/projects/}projects 0.1-SNAPSHOT
[info] The current project is built against Scala 2.12.3
[info] Available Plugins: sbt.plugins.IvyPlugin, sbt.plugins.JvmPlugin, sbt.plugins.CorePlugin, sbt.plugins.JUnitXmlReportPlugin, sbt.plugins.Giter8TemplatePlugin
[info] sbt, sbt plugins, and build definitions are using Scala 2.12.3
so I changed the version of scala in the build.sbt accordingly, ant it worked.
The same internal error can be caused by a version mismatch between the sbt launcher and the project sbt version, as described here:
Internal error: Scala instance doesn't exist or is invalid
In my project, there was no scala version mismatch, but downloading the latest sbt launcher and restarting my session resolved the issue.
I use:
scala version 2.11.8 everywhere in the project, this version is explicitly specified in build.sbt
sbt version 0.13.13, which specified both in project/build.properties and IDE settings
IntelliJ IDEA uses the correct version of scala for tests running and project building (output is in ...target/scala-2.11...), but not for play2 application. The latter one for some reason uses scala 2.10: [info] Compiling 86 Scala sources to .../target/scala-2.10/classes....
The only idea I have is that IDEA uses the default scala of the sbtlauncher (it uses 2.10.6 when run from console), despite the explicit declaration in build file.
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.
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).
It seems you've correctly specified the use of Scala 2.10.2 for compiling your project.
sbt 0.12.4 always uses Scala 2.9.x to compile the build files (i.e. build.sbt and the stuff under project/). This means that plugins for sbt 0.12.x must also be compiled against 2.9.x, which explains what you're seeing.
sbteclipse 2.4.0 requires sbt 0.13. Try sbteclipse 2.2.0 if you want to stay on sbt 0.12.4.
emchristiansen's answer has good additional points.
I have a Play 2.0 app that uses sbt 0.11.2. However when I set up a new Play server, it grabbed the latest version of sbt 0.11.3. Now when I run sbt compile on the new server, it complains
Detected sbt version 0.11.2
Cannot find sbt launcher 0.11.2
Please download:
/sbt-launch.jartypesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/0.11.2
/sbt-launch.jarc2-user/.sbt/.lib/0.11.2
I tried downloading sbt-launch 0.11.2 and putting in the same folder as sbt but still get the same error. Incidentally, is there a difference between play compile vs. sbt compile because play compile works.
Yes I think there is a difference between play compile and sbt compile, if your sbt script uses a different SBT version, in your case vertion 0.11.2 rather than Play's 0.11.3.
Perhaps you should start using SBT 0.11.3 instead?
I just upgraded to Play 2.1-SNAPSHOT (Git rev. f7de038a48, Fri May 25) which uses SBT 0.11.3, and I had to make this change in project/build.properties:
Change from: sbt.version=0.11.2
to: sbt.version=0.11.3
And I linked my SBT bash script to the one included with Play, i.e. 0.11.3 not 0.11.2.
If you're compiling Play20 from source, after running the ./build command in ./Play20/framework, you'll be in the Play shell.
Run the command about and you can check what version of sbt is being run.
> about
[info] This is sbt 0.12.0
[info] The current project is {file:/home/jw/code/Play20/framework/}Root
[info] The current project is built against Scala 2.9.2
[info] Available Plugins: com.typesafe.tools.mima.plugin.MimaPlugin, com.typesafe.sbtscalariform.ScalariformPlugin
[info] sbt, sbt plugins, and build definitions are using Scala 2.9.2
Then in your project directory, change the ./project/build.properties to the correct version.