“Error during sbt execution: No Scala version spec

2019-04-23 15:08发布

I have installed Scala 2.10.3 and SBT 0.13.1. When I execute SBT following Hello, World from the SBT documentation I get the following error message:

"Error during sbt execution: No Scala version specified or detected"

I've tried to add a build.sbt file with the scalaVersion but the error keeps showing up.

Please advise.

I've just downgraded sbt to 0.12.3 and it works ... so what's wrong with 0.13.X ?

4条回答
手持菜刀,她持情操
2楼-- · 2019-04-23 15:28

I've also installed both Scala and SBT on my machine through homebrew and can just run the given simple hello example, so i guess you did something wrong :-)

Please provide a bit more diagnostics, for example:

What is the output of both commands 'which sbt' and 'which scala'? You should see the results as below:

$ which scala
/usr/local/bin/scala

$ which sbt
/usr/local/bin/sbt

$ ls -laF /usr/local/bin/sbt
lrwxr-xr-x  1 rjk  admin  28 Feb  9 13:32 /usr/local/bin/sbt@ -> ../Cellar/sbt/0.13.1/bin/sbt

$ ls -laF /usr/local/bin/scala
lrwxr-xr-x  1 rjk  admin  32 Feb  9 13:38 /usr/local/bin/scala@ -> ../Cellar/scala/2.10.3/bin/scala

And given the directory where you ran the example code from, is it completely empty besides the hw.scala example? Or did you also add the build.sbt or project/build.properties? If that's the case it would be wise to also list that here to spot any problems with them.

查看更多
虎瘦雄心在
3楼-- · 2019-04-23 15:35

I did exactly what @Gopi proposed but this is my repositories file content:

[repositories]

  local
  jcenter: https://jcenter.bintray.com/
  maven-central
  typesafe-ivy-releases: https://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
  sbt-ivy-snapshots: https://repo.scala-sbt.org/scalasbt/ivy-snapshots/, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly

My SBT Version: 1.1.1 java version 1.8 Windows 10

Hope that helps, BR. Paul

查看更多
趁早两清
4楼-- · 2019-04-23 15:39

It is the problem of IDE you are using specially the scala plugin in it. You can get ride of this just go to the folder where the build.sbt is created. Delete the "project" folder and open cmd, run "sbt" command on the folder, a new project folder will be created. Now you can open that in IDE. It may be that you may find some problem very first in ide, if you build the project once , all the problems will go away.

查看更多
不美不萌又怎样
5楼-- · 2019-04-23 15:49

Its not an issue with the upgrade of 0.13.* version. Its the repository cache thats causing the issue. There are possibilities where you have broken / no ivys (when only the jar is downloaded through maven repo) for the sbt jars in your cache.

Once upgraded remove your ivy repo cache (or rename the folder) and remove the .sbt/boot folder (removing this will enable to start from the scratch)

Edit your ./sbt/repositories file and provide preference to the ivy repositories. If you are using proxy repositories which includes both ivy and maven style artifacts, the add it as below

[repositories]

local

maven-local

maven-central-ivy: http://<repository url>, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]

maven-central: http://<repository url>

This will enable especially (org.scala-sbt/sbt/*) to be download with the Ivys xml from where the version / revision and dependencies are picked up for the builds. If only the jar is downloaded from "maven-central", then the error occurs.

查看更多
登录 后发表回答