上周,我们更改了 CI 服务器上的用户目录权限,我们不再拥有对用户主目录的写访问权限。因此 sbt 无法启动,因为它无法~/.ivy使用以下堆栈跟踪写入 etc。
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
Run Code Online (Sandbox Code Playgroud)
我知道我们可以设置一些 sbt 变量,例如引导目录。我还没有找到我们可以配置的所有变量的明确列表,否则默认为用户 home 的子目录。我也没有找到设置默认根目录的方法,这反过来会影响所有这些变量。
谁能指出如何配置 sbt 使其不使用用户的主目录来存放任何文件?
如果您想在不同的位置运行 .ivy,并且您正在使用 sbt extras 启动脚本,那么您应该能够执行以下操作:
sbt -ivy /path/to/ivy package
Run Code Online (Sandbox Code Playgroud)
它会将所有 ivy 内容下载到指定位置并运行您需要的任何命令(在本例中为package)
此处其他答案中提到的常春藤路径选项是解决方案的一部分。正如此答案中所指出的,您需要为 sbt 本身和项目设置 ivy。此外,正如我在这个 sbt github 问题评论中发现的那样,sbt 需要另一个目录来存放它自己的东西。
总的来说,我使用了以下三个 jvm 属性,以便为 sbt 否则使用用户主目录的所有内容使用项目的相对路径:
-Dsbt.global.base=./.sbt/
-Dsbt.ivy.home=./.ivy2/
-Divy.home=./.ivy2/
Run Code Online (Sandbox Code Playgroud)
至少从 sbt 0.13.9 开始,这就是所需要的。
| 归档时间: |
|
| 查看次数: |
2597 次 |
| 最近记录: |