sbt 1.2.8 throwing error in non sudo mode (fedora) - scala

I have installed sbt 1.2.8 on fedora 29 following this instruction:
https://www.scala-sbt.org/1.0/docs/Installing-sbt-on-Linux.html
When I run sbt (don't matter if in project folder or any other place) I get:
java.lang.NoSuchMethodError: scala.Predef$.refArrayOps([Ljava/lang/Object;)[Ljava/lang/Object;
at sbt.xMain.run(Main.scala:74)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
at xsbt.boot.Launch$.run(Launch.scala:109)
at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
at xsbt.boot.Launch$.launch(Launch.scala:117)
at xsbt.boot.Launch$.apply(Launch.scala:18)
at xsbt.boot.Boot$.runImpl(Boot.scala:56)
at xsbt.boot.Boot$.main(Boot.scala:18)
at xsbt.boot.Boot.main(Boot.scala)
Error during sbt execution: java.lang.NoSuchMethodError: scala.Predef$.refArrayOps([Ljava/lang/Object;)[Ljava/lang/Object;
Running sbt with sudo privilages solves the problem. I have also tried downloading tgz package from sbt site and running
./bin/sbt
but with the same result (non sudo - error / sudo - everything ok).
Downgrading to 1.2.7 version also solves the problem but this is not a long term solution.
Do you have any idea what is going on ?

It's not a particularly satisfying answer, but I was able to solve this problem (also on Fedora 29) by deleting the ~/.sbt folder
I don't know what goes on in that folder, so maybe best to make a backup first. After it was deleted, I re-ran sbt and the folder was re-appeared, but sbt no longer crashed.

Related

sbt failed to start with NoClassDefFoundError

On a remote Windows 10 system sbt failes to start with a NoClassDefFoundError:
C:\WORKBENCH\BPF\my-project>sbt -Djavax.net.ssl.trustStoreType=WINDOWS-ROOT -Dsbt.boot.credentials="C:\WORKBENCH\BPF\my-project\credentials.txt" -Dsbt.boot.directory=C:\WORKBENCH\BPF\.sbt\boot -Dsbt.coursier.home=C:\WORKBENCH\BPF\coursier -v
# Executing command line:
"C:\Program Files (x86)\Java\jre1.8.0_321\bin\java.exe"
-Djavax.net.ssl.trustStore="C:\Program Files (x86)\Java\jre1.8.0_321\lib\security\cacerts"
-Djavax.net.ssl.trustStorePassword=changeit
-Xms1024m
-Xmx1024m
-Xss4M
-XX:ReservedCodeCacheSize=128m
-cp
"C:\Program Files (x86)\sbt\bin\sbt-launch.jar"
xsbt.boot.Boot
-Djavax.net.ssl.trustStoreType=WINDOWS-ROOT
-Dsbt.boot.credentials=C:\WORKBENCH\BPF\my-project\credentials.txt
-Dsbt.boot.directory=C:\WORKBENCH\BPF\.sbt\boot
-Dsbt.coursier.home=C:\WORKBENCH\BPF\coursier
java.lang.ClassCastException: java.lang.NoClassDefFoundError cannot be cast to xsbti.FullReload
at sbt.internal.XMainConfiguration.run(XMainConfiguration.java:59)
at sbt.xMain.run(Main.scala:46)
at xsbt.boot.Launch$.$anonfun$run$1(Launch.scala:149)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:176)
at xsbt.boot.Launch$.run(Launch.scala:149)
at xsbt.boot.Launch$.$anonfun$apply$1(Launch.scala:44)
at xsbt.boot.Launch$.launch(Launch.scala:159)
at xsbt.boot.Launch$.apply(Launch.scala:44)
at xsbt.boot.Launch$.apply(Launch.scala:21)
at xsbt.boot.Boot$.runImpl(Boot.scala:78)
at xsbt.boot.Boot$.run(Boot.scala:73)
at xsbt.boot.Boot$.main(Boot.scala:21)
at xsbt.boot.Boot.main(Boot.scala)
[error] [launcher] error during sbt launcher: java.lang.ClassCastException: java.lang.NoClassDefFoundError cannot be cast to xsbti.FullReload
Tried with different SBT versions (1.6.2, 1.5.8, 1.4.9) by changing project/build.properties): The Stack Trace differs depending on the version, but it is always a NoClassDefFoundError.
The SBT version specified in the project is successfully downloaded by the launcher.
I suspect local file permission problems as cause (e.g. due to security policies) therefore i moved the boot and the coursier cache directory. However, this did not bring the desired success.
Does anyone have an idea what the Problem could be?
(I did not do much findings about it.) In my case i could fix it by changing to appropriate java version. Initially i ran with java 18v mistakenly and then changing to java 11v it worked.
I don't have a real diagnosis or causal explanation, but I did solve a similar problem (identical error message, Linux) by clearing out the sbt cache (the .sbt folder within your user directory).

Cannot run sbt on redhat

I tried downloading and running sbt on RedHat using:
curl https://bintray.com/sbt/rpm/rpm | sudo tee /etc/yum.repos.d/bintray-sbt-rpm.repo
sudo yum install sbt
, and I get this error
java.lang.ExceptionInInitializerError
at xsbt.boot.Update.settings$lzycompute(Update.scala:76)
at xsbt.boot.Update.settings(Update.scala:71)
at xsbt.boot.Update.ivyLockFile$lzycompute(Update.scala:93)
at xsbt.boot.Update.apply(Update.scala:100)
at xsbt.boot.Launch.update(Launch.scala:350)
at xsbt.boot.Launch.xsbt$boot$Launch$$retrieve$1(Launch.scala:208)
at xsbt.boot.Launch$$anonfun$3.apply(Launch.scala:216)
at scala.Option.getOrElse(Option.scala:120)
at xsbt.boot.Launch.xsbt$boot$Launch$$getAppProvider0(Launch.scala:216)
at xsbt.boot.Launch$$anon$2.call(Launch.scala:196)
at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:93)
at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:78)
at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:97)
at xsbt.boot.Using$.withResource(Using.scala:10)
at xsbt.boot.Using$.apply(Using.scala:9)
at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:58)
at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:48)
at xsbt.boot.Locks$.apply0(Locks.scala:31)
at xsbt.boot.Locks$.apply(Locks.scala:28)
at xsbt.boot.Launch.locked(Launch.scala:238)
at xsbt.boot.Launch.app(Launch.scala:147)
at xsbt.boot.Launch.app(Launch.scala:145)
at xsbt.boot.Launch$.run(Launch.scala:102)
at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
at xsbt.boot.Launch$.launch(Launch.scala:117)
at xsbt.boot.Launch$.apply(Launch.scala:18)
at xsbt.boot.Boot$.runImpl(Boot.scala:41)
at xsbt.boot.Boot$.main(Boot.scala:17)
at xsbt.boot.Boot.main(Boot.scala)
Caused by: java.lang.RuntimeException: The SHA1 algorithm is not available in your classpath
at org.apache.ivy.core.cache.DefaultRepositoryCacheManager.<clinit>(DefaultRepositoryCacheManager.java:86)
... 29 more
Caused by: java.security.NoSuchAlgorithmException: SHA1 MessageDigest not available
at sun.security.jca.GetInstance.getInstance(GetInstance.java:159)
at java.security.Security.getImpl(Security.java:695)
at java.security.MessageDigest.getInstance(MessageDigest.java:167)
at org.apache.ivy.core.cache.DefaultRepositoryCacheManager.<clinit>(DefaultRepositoryCacheManager.java:84)
... 29 more
Error during sbt execution: java.lang.ExceptionInInitializerError
I'm not sure where the error is coming from. Is it an error in the sbt initialization itself?
Since this is the recommended way to install sbt from the official website, what other ways of installing sbt on redhat would you recommend?
I ended up solving this by installing the bouncy castle jars onto my jvm installation, which were not present in my RedHat vms.
I personally prefer the latest SBT version and a proper wrapper run script for it. There is a very nice script for it written by Paul Phillips (one of the Scala lang contributors). I just have a little shell script get_sbt.sh that downloads the latest version for me:
#!/bin/bash
# Downloads the latest version of SBT runner script which in turn downloads
# SBT launcher JAR and provides lots of convenience methods.
curl -s https://raw.githubusercontent.com/paulp/sbt-extras/master/sbt > sbt && chmod 0755 sbt
You can run it like this:
./get_sbt.sh
It will download the runner script to your current directory, afterwards just run the runner script with:
./sbt
This in turn will download the latest SBT JAR and whatever else is needed will be bootstrapped from here.

sbt fails to start: does not find an (unknown) path

I have downloaded SBT to build a scala project on a Windows 64 bit computer and tried to start SBT. However, I immediately get the following crash (no other output) when entering "sbt" at the prompt (I am in Windows terminal mode):
java.io.IOException: The system cannot find the path specified
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(Unknown Source)
at xsbt.boot.Locks$.apply0(Locks.scala:34)
at xsbt.boot.Locks$.apply(Locks.scala:28)
at xsbt.boot.Update.apply(Update.scala:100)
at xsbt.boot.Launch.update(Launch.scala:350)
at xsbt.boot.Launch$$anonfun$jansiLoader$1.apply(Launch.scala:178)
at scala.Option.getOrElse(Option.scala:120)
at xsbt.boot.Launch.jansiLoader$2f324eef(Launch.scala:173)
at xsbt.boot.Launch.<init>(Launch.scala:150)
at xsbt.boot.Launcher$.apply(Launch.scala:364)
at xsbt.boot.Launch$.apply(Launch.scala:18)
at xsbt.boot.Boot$.runImpl(Boot.scala:41)
at xsbt.boot.Boot$.main(Boot.scala:17)
at xsbt.boot.Boot.main(Boot.scala)
Error during sbt execution: java.io.IOException: The system cannot find the path specified
It finds and runs SBT, but Which path does it try to find? It does not matter in which directory I am starting SBT (i.e. if the directory contains a project to build or not)
I have tried with a clean system (new installed eclipse Luna with scala IDE, latest java JDK1.8.0_73) and tried to install SBT 0.13.11 directly from an msi file as well as manually (I do not use the SBT bundled in scala IDE). No difference. SBT won't start. And no hint on which path it is looking for. What can be the cause for this?

sbt fails with java.lang.NoClassDefFoundError: sbt/ConsoleOut$

After using sbt for some time, something failed and I can't run sbt on my Ubuntu machine. I get this exception no matter what I do. Even running sbt help causes the following error:
java.lang.NoClassDefFoundError: sbt/ConsoleOut$
at sbt.StandardMain$.<init>(Main.scala:52)
at sbt.StandardMain$.<clinit>(Main.scala)
at sbt.xMain.run(Main.scala:26)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:57)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:77)
at xsbt.boot.Launch$.run(Launch.scala:57)
at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:45)
at xsbt.boot.Launch$.launch(Launch.scala:65)
at xsbt.boot.Launch$.apply(Launch.scala:16)
at xsbt.boot.Boot$.runImpl(Boot.scala:32)
at xsbt.boot.Boot$.main(Boot.scala:21)
at xsbt.boot.Boot.main(Boot.scala)
Caused by: java.lang.ClassNotFoundException: sbt.ConsoleOut$
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 12 more
Error during sbt execution: java.lang.NoClassDefFoundError: sbt/ConsoleOut$
I reinstalled the JDK and of course sbt, but it didn't help. The only thing I remember doing was installing the new IntelliJ IDEA 13. Could this be related?
the only thing I remember doing was installing the new intellij (v13). Is this related?
It could be related.
Try:
rm -rf ~/.ivy/cache
mv ~/.sbt ~/.sbt.old
Most probably this issue comes from the IntelliJ IDE, Close all the running processes of the IDE and start it again.
In sbt:
clean
Results in re-resolution of ivy artifacts on next compile, without having to clear the ivy cache.
If the ivy itself is the problem then above solution is a good fallback.
In windows, log with cygwin or any other terminal emulator and run below commands:
rm -rf ~/.sbt
rm -rf ~/.ivy2
rm -rf ~/.ivy
Alternatively, it could be that your project uses a too old version of sbt, somehow breaking some dependencies.
Update sbt.version in project/build.properties and it should work again.

sbt 0.13.0 JLine incompatibility detected

I have a problem with starting a play 2.2.0 app on my mac with mountain lion and java 7:
[ERROR] Terminal initialization failed; falling back to unsupported
java.lang.IncompatibleClassChangeError: Found class jline.Terminal, but interface was expected
at jline.TerminalFactory.create(TerminalFactory.java:101)
at jline.TerminalFactory.get(TerminalFactory.java:159)
at sbt.ConsoleLogger$.ansiSupported(ConsoleLogger.scala:85)
at sbt.ConsoleLogger$.<init>(ConsoleLogger.scala:79)
at sbt.ConsoleLogger$.<clinit>(ConsoleLogger.scala)
at sbt.GlobalLogging$.initial(GlobalLogging.scala:40)
at sbt.StandardMain$.initialGlobalLogging(Main.scala:54)
at sbt.StandardMain$.initialState(Main.scala:60)
at sbt.xMain.run(Main.scala:26)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:57)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:77)
at xsbt.boot.Launch$.run(Launch.scala:57)
at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:45)
at xsbt.boot.Launch$.launch(Launch.scala:65)
at xsbt.boot.Launch$.apply(Launch.scala:16)
at xsbt.boot.Boot$.runImpl(Boot.scala:32)
at xsbt.boot.Boot$.main(Boot.scala:21)
at xsbt.boot.Boot.main(Boot.scala)
java.lang.IncompatibleClassChangeError: JLine incompatibility detected. Check that the sbt launcher is version 0.13.x or later.
at sbt.ConsoleLogger$.ansiSupported(ConsoleLogger.scala:96)
at sbt.ConsoleLogger$.<init>(ConsoleLogger.scala:79)
at sbt.ConsoleLogger$.<clinit>(ConsoleLogger.scala)
at sbt.GlobalLogging$.initial(GlobalLogging.scala:40)
at sbt.StandardMain$.initialGlobalLogging(Main.scala:54)
at sbt.StandardMain$.initialState(Main.scala:60)
at sbt.xMain.run(Main.scala:26)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:57)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:77)
at xsbt.boot.Launch$.run(Launch.scala:57)
at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:45)
at xsbt.boot.Launch$.launch(Launch.scala:65)
at xsbt.boot.Launch$.apply(Launch.scala:16)
at xsbt.boot.Boot$.runImpl(Boot.scala:32)
at xsbt.boot.Boot$.main(Boot.scala:21)
at xsbt.boot.Boot.main(Boot.scala)
Error during sbt execution: java.lang.IncompatibleClassChangeError: JLine incompatibility detected. Check that the sbt launcher is version 0.13.x or later.
It's not really linked to play since I got the same error when I start directly sbt in that directory.
So I tried a couple of things:
removed all sbt related stuff from my home dir and tried to use the sbt script from https://github.com/paulp/sbt-extras/blob/master/sbt -> same problem
removed all jars from my ivy repo dir and started again sbt -> same problem
downloaded a sbt launcher directly (version 0.13.0) -> same problem
tried with java 6 -> same problem
tried to debug sbt to figure out what's wrong but all I found out was that jline does not recognize that it should use a UnixTerminal (which I got working by setting systemProperties) but then again -> same error
It's somehow related to some strange linking I think because the class version for the terminal which should be used seems to be old. At least this is what the jvm is complaining about.
I tried it on a virtual box with ubuntu which worked fine so I think my system is a mess or I did something completely wrong.
Someone any ideas?
I had same problem. My project is using SBT 0.13
Turned out I need to upgrade SBT Launcher to 0.13 version as well.
If you start the JVM with verbose class loading enabled (-verbose:class), that might help troubleshoot where the offending JLine classes are coming from. Perhaps you have a JLine jar in one of your JVM extension directories, probably ~/Library/Java/Extensions or /System/Library/Java/Extensions.
This error can also happen if you use an SBT launcher from 0.12 in an SBT 0.13 project, as suggested in the error message.
Try updating SBT version to 0.13. Just download the sbt tar file and change the path in your .bash_profile file. Try again running sbt command in the project directory. That should fix the issue.