将 sbt 配置为不使用用户主目录 [英] Configure sbt to not utilize user home directory

查看:46
本文介绍了将 sbt 配置为不使用用户主目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上周我们更改了 CI 服务器上的用户目录权限,我们不再拥有对用户主目录的写入权限.因此 sbt 无法启动,因为它无法使用以下堆栈跟踪写入 ~/.ivy 等.

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

我知道我们可以设置一些 sbt 变量,例如 引导目录.我还没有找到我们可以配置的所有变量的明确列表,否则默认为用户 home 的子目录.我也没有找到设置默认根目录的方法,这会反过来影响所有这些变量.

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.

谁能指出如何配置 sbt 使其不使用用户的主目录来存放任何文件?

Can anyone point out how to configure sbt such that it does not use the user's home directory for any files?

推荐答案

此处其他答案中提到的 ivy 路径选项是解决方案的一部分.正如这个答案中所指出的 您需要为 sbt 本身和项目设置 ivy.此外,正如我在 this sbt github issue comment 上发现的那样,sbt 还需要它自己的东西的另一个目录.

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.

总的来说,我使用了以下三个 jvm 属性,以便为 sbt 否则使用用户主目录的所有内容使用项目的相对路径:

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/ 

至少从 sbt 0.13.9 开始,这是需要的.

At least as of sbt 0.13.9, this is what is needed.

这篇关于将 sbt 配置为不使用用户主目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆