"Error during sbt execution: No Scala version specified or detected" with SBT from Homebrew - scala

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 ?

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.

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.

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

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.

Related

Errors when creating a Scala project with sbt

When I create a Scala project with sbt I get the following error:
ERROR org.eclipse.jgit.util.FS - caught exception in FS.readPipe()
java.io.IOException: Cannot run program "bash" (in directory "C:\Users\xyz")....
Though it will create the project and the correct structure. But when I go into the new folder of the project and run the sbt command, this error occurs:
Unresolved dependency: com.typesafe.sbteclipse#sbteclipse-plugin;5.1.0: not found
I put the dependency addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.1.0") in the file project/plugins.sbt.
EDIT When I put the plugins.sbt file into the ~/.sbt/0.13/plugins/ folder, then I can start sbt from the project folder but it will throw an error when in sbt I type in the command eclipse, saying it wouldn't be a valid command.
I use JDK 1.8, sbt 0.13.16 and Scala IDE 4.7.0
Why is this happening? How can I solve it?
I found the problem. There is a file called build.properties (i.e. hello-world/project/build.properties) and in this file I had a this line: sbt.version=1.00.00. I changed this to sbt.version=0.13.16 then everything worked. I hope this helps others with a similar problem.
Though it is still not clear why sbt new scala/hello-world creates the project with sbt.version=1.00.00 by default. Especially when typing sbt about will output that the used version is 0.13.16.
Edit: It is choosing version 1.00.00 (even when you download the 0.13.16 installer) because this is the newest version, if you want to run an older (still supported) version you will have to change it in the above mentioned sbt file.

Why does sbt report "Error: Could not retrieve sbt 0.13.11"?

In a Scala project I updated the build.properties from 0.13.8 to 0.13.11. That "broke" sbt as it does not start anymore, i.e. it cannot download the 0.13.11 jars?! sbt prints a list of tried repo's, but the repo.typesafe.com was not one of them.
My local installed sbt is 0.13.8.
For some reason the scala-sbt jars are not available anymore in Typesafe's Bintray. Largest version there is 0.13.9.
I know the place to get it is https://repo.typesafe.com/typesafe/ivy-releases/, but how do I tell sbt to use this repo?
I have already tried:
adding a resolver to plugins.sbt
adding a resolver to build.sbt
adding the repo to .sbt/repositories
but I cannot get it working.
How to tell sbt where to get binaries?
Make sure that you're using sbt (launcher) that's at the same version of higher than the version used in your project.
Execute sbt about in an empty directory and find [info] This is sbt X.Y.X.
Make sure that you don't use ~/.sbt/repositories file that sets up the repositories used to resolve artifacts.
try to set your https proxy Information into http.proxyHost and http.proxyPort. This solved it for me.

intellij/activator/sbt are downloading dependencies previously downloaded by the other

I'm not an expert with sbt so probably my question is a bit noob, but I've notice than when I create a project and download its dependencies with sbt, if I open the project with intellij, all the dependencies are redownloaded again, the same happen in the inverse orden intellij->sbt and also activator..
my (poor) knowledge about sbt is than this use ivy and the dependencies are downloaded in ~/.ivy2/ folder...that is where sbt is downloading my deps, but seems than intellij is using other folder.
personally I don't use so much activator, but I would like configure sbt and intellij for use the same ivy path...
2)recently I publish finagle-postgre to my local ivy using sbt +publishLocal, I can check in my ivy folder
/home/yo/.ivy2/local/com.twitter/finagle-postgres_2.11/0.1.0-SNAPSHOT
but unfortunately intellij is unable to resolve this dependency, I try adding this line to my build
resolvers += Resolver.file("Local", file( Path.userHome.absolutePath + "/.ivy2/local"))(Resolver.ivyStylePatterns)
but seems not works
3) the path where is downloaded the dependencies is related to which sbt-launch.jar file is used? How can I know what sbt-lauch.jar file is using sbt right now...
thanks guys!
If we're talking about IntelliJ appearing to download artifacts after they've already been downloaded by SBT/Activator, then it turns out that it's probably just that IntelliJ is downloading the sources - it's not redownloading the binary artifacts, just the source artifacts that accompany them.
This isn't readily apparent when you're looking at the Refreshing SBT project task in the Background Tasks popup, because the full download path is truncated, so you see something like this:
[info] downloading https://repo1.maven.org/maven2/org/apache/httpcompo...
..it's natural to assume that this is the same binary artifact you already saw SBT download on the console, but you can see the full story if you check the full log (go Help -> Show Log in files and open sbt.last.log in the file browser).
You'll see that the only artifacts getting downloaded end with -sources.jar:
$ grep repo1.maven.org /home/roberto/.IntelliJIdea2016.3/system/log/sbt.last.log
[info] downloading https://repo1.maven.org/maven2/org/apache/httpcomponents/httpclient/4.3.6/httpclient-4.3.6-sources.jar ...
[info] downloading https://repo1.maven.org/maven2/com/googlecode/javaewah/JavaEWAH/0.7.9/JavaEWAH-0.7.9-sources.jar ...
[info] downloading https://repo1.maven.org/maven2/org/pegdown/pegdown/1.2.1/pegdown-1.2.1-sources.jar ...
[info] downloading https://repo1.maven.org/maven2/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3-sources.jar ...
```
If you don't have the Sources checkbox checked when you're doing Import project, these source downloads won't happen.
tested using IntelliJ 2016.3.5 and Scala plugin v2016.3.9
First, the activator is just a launcher for SBT itself, so there should be no difference in behaviour.
Second, IntelliJ also uses the files in ~/.ivy2 by default if you have not told it otherwise (by setting SBT_OPTS environment variable for example, but that depends on your IntelliJ version).
A difference might result if you're using different scala versions (e.g. 2.10.x vs. 2.11.x) when you do not have set the scalaVersion in your project explicitly. Then, each tool would download the corresponding libraries for the appropriate scala version it has configured by default.
Another thing is that IntelliJ will download source and javadoc jars for each dependency if you have enabled that in your settings which might look like it downloads the dependencies again.
Note, I'm wildly guessing here because you have not included any output of the programs you're using, so it's hard to say what the real problem is.

Installing SBT on Win 7 64 bit

I want to install Apache Spark for testing purpose. For that I found out that Scala and sbt are necessary. I downloaded scala msi and installed it. For installing sbt I tried various methods but am unable to do so. Can someone tell me what am I doing wrong. What I did is
Install Scala msi
Download sbt msi and install it.
Set sbt_home and path variable to the location where sbt is extracted. Then I opened cmd to check my sbt version by using sbt sbt-version I am getting the following error **unresolved dependency:
org.fusesource.jansi#jansi;1.11: not found
Error during sbt execution: Error retrieving required libraries (see C:\Users\ashish-b\.sbt\boot\update.log for complete log) Error: Could not retrieve jansi 1.11 **
Whats wrong in it?
I saw this issue as well when connecting to the internet via a corporate proxy. In this case, sbt couldn't download its dependencies.
We work with a proxy Maven repository for depedencies. Configure sbt to use a proxy repo.
Our sbt repositories file looks like this:
[repositories]
local
local-maven: file:///C:/data/maven_repo/
aaa-ext-ivy-proxy: http://nexus-ext.company.net:8081/nexus/content/groups/ivy-public/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
aaa-ext-maven-proxy: http://nexus-ext.company.net:8081/nexus/content/groups/public/
aaa-int-maven-repo: http://nexus-int.company.net:8081/nexus/content/groups/public/
Or you can also configure the proxy server directly for SBT, see this question.

Scala SBT / Maven2 Error on OSX: "Error Opening Zip File" -> MissingRequirementError

I have a project that builds well on Unix boxes (http://www.github.com/jhclark/ducttape).
However, using SBT 0.11.2 (and a few other versions of SBT), it will not build on my Mac (OSX 10.5). I get the following cryptic error message:
$ ~/bin/sbt compile (master*? 20:11)
[info] Loading project definition from /Users/jon/Documents/workspace- scala/ducttape/project
[info] Set current project to ducttape (in build file:/Users/jon/Documents/workspace-scala/ducttape/)
[info] Compiling 104 Scala sources to /Users/jon/Documents/workspace-scala/ducttape/target/scala-2.9.2/classes...
[error] error while loading <root>, error in opening zip file
[error] {file:/Users/jon/Documents/workspace-scala/ducttape/}default-024416/compile:compile: scala.tools.nsc.MissingRequirementError: object scala not found.
[error] Total time: 2 s, completed May 27, 2012 8:12:09 PM
This happens even after I clean things out thoroughly with:
sbt clean clean-files
rm -rf ~/.ivy2 ~/.m2 ~/.sbt
I suspect that the real error is happening in Maven2, which SBT uses for dependency management (see also Maven : error in opening zip file when running maven).
However, I'm stumped after several days. Any ideas?
I had similar problems when attempting to use an older version of the sbt-extras launcher with sbt-0.11.3. In my case, it attempted to download a file that didn't exist, and attempted to unzip the 404 error page. The most recent sbt-extras launcher has been fixed for sbt-0.11.3.
Yours sounds different, but they may be due to the the shutdown of scala-tools.org. If you can, I recommend upgrading to sbt-0.11.3.
If you need to continue to use 0.11.2, you should use the 0.11.3-2 launcher, put sbt.version=0.11.2 in project/build.properties, and disable the scalaTools repo in your build.sbt. Mark Harrah posted info on the SBT mailing list.
If this doesn't help, for some reason you're downloading corrupted .jars from somewhere.
Run the command find ~/.ivy2 ~/.m2 ~/.sbt -name "*.jar" -exec unzip -qqt {} \; to find which jar(s) are corrupted. The contents of the corrupt jar may give you a clue as to what's going wrong.
For completion, I had the same problem and it was a corrupt zip/jar file.
However, Dave's command line checks for the usual classpath directories, where your jar may be.
The one causing me troubles was in fact in my projects ./lib folder. I struggled with this for hours, hopefully this may help someone else.
PS: Thanks a lot Dave!
I just had the same problem (on OSX, and with Scala 2.10.2), but the problem turned out not to be in any of my dependency manager repos, or with SBT or Scala (as for some people).
I had put a JAR into /Library/Java/Home/lib/ext/ for other reasons, but didn't make it group- and world-readable. Only root (it's owner) could read it. I tweaked the permissions, and voila. Scala and SBT suddenly work again.
cd /Library/Java/Home/lib/ext
sudo chmod g+r bcprov-jdk15on-1.47.jar
sudo chmod g+a bcprov-jdk15on-1.47.jar