Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure sbt to not utilize user home directory

Tags:

scala

sbt

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?

like image 871
joescii Avatar asked Dec 01 '15 21:12

joescii


1 Answers

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.

like image 195
joescii Avatar answered Oct 17 '22 04:10

joescii