Trying to install SBT-0.13.8 for Windows 7 installs SBT version 0.12.4 - scala

I have (multiple times) tried to install SBT-0.13.8 from the SBT download page via the SBT-0.13.8-MSI button and I always end up getting an SBT version which shows the following output
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Loading project definition from C:\Users\Tina\Desktop\example\project\project
error: error while loading CharSequence, class file 'C:\Program Files\Java\jre1.
8.0_20\lib\rt.jar(java/lang/CharSequence.class)' is broken (bad constant pool tag 15 at byte 1470)
[error] Type error in expression
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? i
[warn] Ignoring load failure: no project loaded.
> about
[info] This is sbt 0.12.4
[info] No project is currently loaded
[info] sbt, sbt plugins, and build definitions are using Scala 2.9.2
SBT produces an error message and (!) shows itself as version 0.12.4.!!!
I really made sure that I have no other version of SBT installed and I even made a reboot before re-installing it but nothing changed. SBT files have a creation date of March, 21, 2015. This seems to be the newest version but why does this version show up as 0.12.4 and does not work with JDK1.8?

Looks like the directory you're in is wrong, you want to launch sbt from C:\Users\Tina\Desktop\example\project not C:\Users\Tina\Desktop\example\project\project (note 1 project less).
The second problem you're having is you're trying to use sbt 0.12.4 with Java 8. sbt 0.12.4 uses (as can be seen from the output) Scala 2.9.2 which doesn't work with Java 8. I would recommend migrating to sbt 0.13.8, but if not you could always downgrade to Java 7.
Edit after comments below
The progfun Coursera course download is still configured with sbt
0.12.4 which you're having trouble building because you are using Java 8.
I had a quick go at trying to see if upgrading the project to 0.13.8 would work (FYI it involves editing project/build.properties), but then plugins need to be upgraded, then meta-build code needed to be changed because of namespace changes..
Unless you're willing to experiment more and work you're way through the various changes required to use latest sbt and latest Java (which is what I would do if this were for myself), I would recommend as an alternative to:
Downgrade to Java 7
Notify the relevant people involved in running the course that the source material should be updated as it demonstrably does not work on latest, stable Java.
If your default Java is Java 8 but you want to switch to Java 7 for this out-of-date project setup, you need to create an .sbtopts file at the root of the project containing (note: on separate lines!):
-java-home
C:\Users\Tina\PATH\TO\YOUR\JAVA\HOME

Related

Sbt not loading the project from its current directory

When I run SBT in my Scala project that contains a build.sbt file, SBT seems to ignore it and loads the project definition from a different folder and set the current project to that different directory hsperfdata which is weird because this is used as part of Java's performance counter which has nothing to do with what I'm trying to do.
Also SBT was installed via SDKMAN and when I try to specify a lower SDK version 1.2.8 instead of 1.4.6 it will always use 1.4.6. version 1.2.8 is also specified in my build.properties file as well.
My stack trace:
xxxxx#MC-N369748 topic-api % sbt
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] welcome to sbt 1.4.6 (AdoptOpenJDK Java 1.8.0_275)
[info] loading project definition from /private/var/folders/hs/0vkhntfd557c8z8g8b_p7ly00000gp/T/hsperfdata_adu-tp01/project
[info] set current project to hsperfdata_adu-tp01 (in build file:/private/var/folders/hs/0vkhntfd557c8z8g8b_p7ly00000gp/T/hsperfdata_adu-tp01/)
[info] sbt server started at local:///Users/xxxxx/.sbt/1.0/server/143baa47709c908603e6/sock
[info] started sbt server
sbt:hsperfdata_xxxxx>
When we had this issue, it was caused by OS X restricting the permissions of the java executables. Since the process is not able to read/write to the current directory, sbt diverts to the tmp folder.
In System Preferences => Security & Privacy make sure the Full Disk Access property is turned on for the appropriate executables (probably java and javac in this case) or move your source code our of what OS X considers the protected part of the file system (we moved our builds from the user home directory to /code and sbt worked fine).

Compilation error in the Scala/Play example application for Heroku using Intellij

I am trying to compile the scala/Play framework example application on my local machine, but I am getting compilation errors when trying to compile using the SBT console in IntelliJ:
error: scala.reflect.internal.MissingRequirementError: object java.lang.Object in compiler mirror not found.
I also got this message in the event log related to different SBT versions:
14:48 Started sbt shell with sbt version 0.13.18 instead of 0.13.11 configured by project.
Update sbt version
Disable version override
Any suggestions on how to fix this?
For the first error
error: scala.reflect.internal.MissingRequirementError: object java.lang.Object in compiler mirror not found.
You might want to try and ensure that you are using a compatible java version. Like #cbley suggested, try making you are using version 8 of the JDK.
For the second error
14:48 Started sbt shell with sbt version 0.13.18 instead of 0.13.11 configured by project.
Update sbt version
Disable version override
Its just suggesting you update the version of sbt (which is most likely declared in your build.properties file in a folder called project. You can just search for it by double tapping shift in IntelliJ. But you are safe to ignore it if you cloned some example repository as well.
check

Installing sbt on Windows 10 for Scala course

Instructions for the course say to use verion 0.13.x.
I installed the latest msi from the sbt site, but when I type "sbt about", I get:
Microsoft Windows [Version 10.0.15063]
(c) 2017 Microsoft Corporation. All rights reserved.
C:\Users\reall>sbt about
Error: Unable to access jarfile
Copying runtime jar.
The filename, directory name, or volume label syntax is incorrect.
Error: Unable to access jarfile
"C:\Users\reall\.sbt\preloaded\org.scala-sbt\sbt\"1.0.2"\jars\sbt.jar"
Java HotSpot(TM) 64-Bit Server VM warning: Ignoring option MaxPermSize; support was removed in 8.0
[info] Loading project definition from C:\Users\reall\project
[info] Set current project to reall (in build file:/C:/Users/reall/)
[info] This is sbt 1.0.2
[info] The current project is {file:/C:/Users/reall/}reall 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
i.e., a jar file error and the sbt version 1.0.2.
Any idea what I'm doing wrong?
You are not doing anything wrong, it's just that the required version 0.13.x is not the latest anymore. So you can either follow #dmytro-mitin's answer and reinstall sbt, or you can still use the one you already have: what you installed now is the sbt launcher, it can be used to run different versions of sbt depending on a project. So it's not important which launcher version you are using (unless you're working on something very sbt-specific).
Normally, every sbt project has a project/build.properties file with the sbt version that is needed to work with it:
sbt.version=0.13.16
So you can change (or create) this file and when you run sbt in the project root folder, it will launch sbt version 0.13.16.
Another way to launch specific version of sbt is to run it with the -sbt-version option :
sbt -sbt-version 0.13.16
or using -D flag:
sbt -Dsbt.version=0.13.16
which has exactly the same effect as editing project/build.properties.
Install not the latest version. The latest one is 1.0.2.
Install 0.13.16.
You can download it here: http://www.scala-sbt.org/download.html
There are msi and zip files.
Installing sbt on Windows

sbt console doesn't allow input

I've been trying to use sbt for one of my projects, however I've ran into the following problem - when I try to use sbt console to get the scala's REPL, it just doesn't allow any input. Example session:
[lared#lt foo]$ sbt
[info] Set current project to foo (in build file:/tmp/foo/)
> console
[info] Updating {file:/tmp/foo/}foo...
[info] Resolving org.scala-lang#scala-reflect;2.10.3 ...
[info] Done updating.
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.10.3 (OpenJDK 64-Bit Server VM, Java 1.8.0_25).
Type in expressions to have them evaluated.
Type :help for more information.
scala>
I can not type anything. It doesn't seem to take much RAM/CPU time. The problem is reproducible in any directory, regardless of if it does have a proper project structure (for example the SBT Hello World tutorial) or not.
I'm using sbt 0.13.1 and the JDK/Scala versions as seen above on Fedora 21.
The problem was solved by deleting ~/.ivy2/ and (perhaps unrelated) migration to Oracle Java 1.7 SDK.
I could not find a way to get the Fedora 24 installed sbt 0.13.1 console to work either so I downloaded the latest sbt (currently 0.13.12), unzipped into /opt and add the sbt binary to my path before /usr/bin/sbt.
The earlier suggestion to delete ~/.ivy2 did not work for me.

Sbt 0.12.4+ required on project import

I'm currently reading the Play for Scala: Covers Play 2 book by Peter Hilton (publisher: Manning) , and trying to stick to the versions they've outlined in the book (Play version 2.1.1).
I downloaded the new IntelliJ IDEA 14 CE app and installed it. I'm currently importing the project, and it's failing because it wants a version of sbt that is 0.12.4 or greater.
This issue occurred in 13 the other day, but I haven't had time to resolve it, so please, no recommendations to go back to 13 :)
Here is the meat of the issue:
When I type sbt --version on the CLI, it prints sbt launcher version 0.13.6. I have a "greater" version, but it appears that IDEA doesn't recognize this.
In an effort to specify my own SBT launcher JAR, I pointed my custom launcher (in IDEAs global settings) to the one in /usr/local/Cellar/sbt/0.13.6/libexec/sbt-launch.jar, but the build also failed with the same error.
As you may have guessed at this point, I have used Homebrew to install and manage Scala and sbt. When I first started working with Scala back in February, I remember having to make a few small tweaks in my settings to get IDEA to find Scala, but my version of IDEA 14 is totally fresh -- I did not import any previous settings. I downloaded the Scala and sbt plugins and they appear to be properly configured after a cursory look and creation of a new test project.
Here is what I'm failing to understand:
First, and most obvious, why would an sbt version that meets the supposed requirement (0.12.4+) fail with version 0.13.*?
Second, is the bundled sbt with IDEA also greater than this version? Is there possibly an sbt flag somewhere in my system that's pointing it to an earlier version? A side note, I have a few versions of sbt in my "Cellar", but all are greater than 0.13.
Many thanks for your help!
I had a look at the code samples from Manning's website, and the project/build.properties files for each project specify sbt.version=0.12.2. My guess is that the Intellij Scala plugin only supports SBT 0.12.4, and cannot import you project which is configured to use an older version (hence why it recommends that you "update your project definition").
You should try using sbt.version=0.12.4 in the project/build.properties file.
Generally speaking, keep in mind that when an SBT version is specified in project/build.properties, the SBT launcher downloads the specified version and uses it to build the project. In your case, that means that the SBT 0.13.6 launcher will download SBT 0.12.2 and use that version to build the project.