javascalasbt

SBT Java The system cannot find the path specified


I am getting the below error, tried various versions of java still I am getting the error

$ ./sbt compile

java.io.IOException: The system cannot find the path specified
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createTempFile(File.java:2063) 
at java.io.File.createTempFile(File.java:2109) 
at sbt.StandardMain$$anonfun$initialGlobalLogging$1.apply(Main.scala:68) 
at sbt.StandardMain$$anonfun$initialGlobalLogging$1.apply(Main.scala:68) 
at sbt.GlobalLogBacking$.apply(GlobalLogging.scala:38) 
at sbt.GlobalLogging$.initial(GlobalLogging.scala:44) 
at sbt.StandardMain$.initialGlobalLogging(Main.scala:68) 
at sbt.StandardMain$.initialState(Main.scala:77) 
at sbt.xMain.run(Main.scala:32) 
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: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
$ java -version java version "1.8.0_451" 

Java(TM) SE Runtime Environment (build 1.8.0_451-b10) Java HotSpot(TM) 64-Bit 
Server VM (build 25.451-b10, mixed mode)

Solution

  • Looking at what the code does I suspect you might not have access to the temporary directory where the global sbt log is supposed to be stored (maybe it's a system directory and you access to those is limited on your laptop?).

    If that's the case, you might want to try the following:

    mkdir /some/path/you/know/you/can/access
    ./sbt -Djava.io.tmpdir=/some/path/you/know/you/can/access compile
    

    As a side note, the line numbers in the stack trace suggest that you are using a version of sbt not newer than 0.13.18, which is several years old. Java 8 is also quite old, although the specific version you are using seems a recent patch version. You might want to consider upgrading at least sbt.