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

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?

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).

Sudden problem with Apache log4j Appender when trying to launch SBT

I was executing a scala program with SBT and needed to stop the execution, so I hit Ctrl+c to end execution, which also ends the execution of SBT. I've done this a thousand times, but this time SBT wouldn't restart, and gives me this error:
java.lang.NoClassDefFoundError: org/apache/logging/log4j/core/Appender
at sbt.StandardMain$.initialGlobalLogging(Main.scala:114)
at sbt.StandardMain$.initialState(Main.scala:136)
at sbt.xMain.run(Main.scala:70)
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)
Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.core.Appender
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 14 more
[error] [launcher] error during sbt launcher: java.lang.NoClassDefFoundError: org/apache/logging/log4j/core/Appender
I tried installing a new version of SBT but that didn't work, and I get the same error.
I'm at a complete loss as to how to fix this problem. I really don't even know what the problem is. Thanks for any help.
I was able to get things working but I won't guarantee this would be a fix for everyone. Deleting my .sbt folder and restarting sbt worked. It created a new .sbt folder and everything is working correctly now. I only use sbt for compiling scala code so there isn't much that depends on sbt. Definitely back up your old .sbt folder if you're going to try this route.

sbt 1.2.8 throwing error in non sudo mode (fedora)

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.

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.

Configure sbt to not utilize user home directory

Last week we had the user directory permissions changed on our CI servers and we no longer have write access to the user home directory. Hence sbt fails to boot because it cannot write to ~/.ivy etc with the following stacktrace.
java.io.IOException: No such file or directory
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(File.java:1006)
at xsbt.boot.Locks$.apply0(Locks.scala:34)
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)
Error during sbt execution: java.io.IOException: No such file or directory
I know that there is a smattering of sbt variables we can set, such as the boot directory. I've not yet found a definitive list of all the variables that we can configure that otherwise default to a subdirectory of user home. I also have not found a way to set the default root directory, which could in turn impact all of these variables.
Can anyone point out how to configure sbt such that it does not use the user's home directory for any files?
The ivy path options mentioned in the other answers here were part of the solution. As pointed out in this answer you need to set ivy for both sbt itself and the project. Furthermore as I discovered on this sbt github issue comment, sbt needs yet another directory for its own stuff.
In total, I used the following three jvm properties in order to use a relative path to the project for everything that sbt otherwise uses the user's home directory for:
-Dsbt.global.base=./.sbt/
-Dsbt.ivy.home=./.ivy2/
-Divy.home=./.ivy2/
At least as of sbt 0.13.9, this is what is needed.
If you would like to run with your .ivy in a different location, and you're using sbt extras boot script, then you should just be able to do:
sbt -ivy /path/to/ivy package
and it'll download all the ivy stuffs to the location specified and run whatever command you need (in this example, package)
You can set -ivy when using sbt-extras (preferable), or you can use a JVM property:
-Dsbt.ivy.home=/path/to/ivy
I've also used this:
-Divy.default.ivy.user.dir=/path/to/ivy