5

为了构建 spark 项目,我尝试使用 sbt。发生以下异常:

java.io.IOException: No locks available
    at sun.nio.ch.FileChannelImpl.lock0(Native Method)
    at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:871)
    at java.nio.channels.FileChannel.tryLock(FileChannel.java:962)
    at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:88)
    at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:81)
    at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:102)
    at xsbt.boot.Using$.withResource(Using.scala:11)
    at xsbt.boot.Using$.apply(Using.scala:10)
    at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:62)
    at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:52)
    at xsbt.boot.Locks$.apply0(Locks.scala:31)
    at xsbt.boot.Locks$.apply(Locks.scala:28)
    at xsbt.boot.Update.apply(Update.scala:100)
    at xsbt.boot.Launch.update(Launch.scala:279)
    at xsbt.boot.Launch.xsbt$boot$Launch$$retrieve$1(Launch.scala:149)
    at xsbt.boot.Launch$$anonfun$3.apply(Launch.scala:157)
    at scala.Option.getOrElse(Option.scala:120)
    at xsbt.boot.Launch.xsbt$boot$Launch$$getAppProvider0(Launch.scala:157)
    at xsbt.boot.Launch$$anon$2.call(Launch.scala:142)
    at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:98)
    at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:81)
    at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:102)
    at xsbt.boot.Using$.withResource(Using.scala:11)
    at xsbt.boot.Using$.apply(Using.scala:10)
    at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:62)
    at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:52)
    at xsbt.boot.Locks$.apply0(Locks.scala:31)
    at xsbt.boot.Locks$.apply(Locks.scala:28)
    at xsbt.boot.Launch.locked(Launch.scala:178)
    at xsbt.boot.Launch.app(Launch.scala:93)
    at xsbt.boot.Launch.app(Launch.scala:91)
    at xsbt.boot.Launch$.run(Launch.scala:51)
    at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:45)
    at xsbt.boot.Launch$.launch(Launch.scala:65)
    at xsbt.boot.Launch$.apply(Launch.scala:16)
    at xsbt.boot.Boot$.runImpl(Boot.scala:31)
    at xsbt.boot.Boot$.main(Boot.scala:20)
    at xsbt.boot.Boot.main(Boot.scala)
Error during sbt execution: java.io.IOException: No locks available

我尝试过的 sbt 版本:0.11.3-2 和 0.13.0 我还尝试更改 sbt 引导目录以避免权限问题。

任何想法,我做错了。

4

3 回答 3

4

SBT 依赖你的 jvm 的属性“user.home”作为工作目录,并且SEEMS在那里获取锁,如果你的“user.home”指向一个没有安装 NFS 锁服务的 NFS 目录,那么你会得到“没有可用的锁”错误。

我多次遇到此错误(另一种情况是 maven 尝试在 $HOME/.m2/... 下获取一些锁)。你有两个选择:

  • 安装 NFS 锁定服务
  • 通过传递属性 -Duser.home=/path/in/local/disk 告诉 sbt 不要在 NFS 中使用你的目录。例如。
    • sbt clean compile -Duser.home=/disk1/myhome
于 2015-01-13T16:16:15.200 回答
1

默认情况下,sbt 在启动或进行依赖解析时会尝试获取独占锁。这是为了避免缓存损坏或删除另一个进程正在使用的 JAR 文件(这可能会导致一些非常奇怪的错误)。

这种锁定通常与分布式文件系统不兼容。有时它甚至在具有意外实现的本地文件系统上失败。检查您的 FS 以查看 Java 是否支持对其进行锁定。

您应该能够通过以下方式禁用此锁定:

sbt -Dsbt.boot.lock=false

另外,如果您有自己的sbt.boot.properties文件,则需要以下内容:

[boot]
lock: false

这将禁用启动器内的锁定功能,进而禁用所有使用此功能的 sbt 项目的锁定。AFAIK 这意味着 sbt 中的所有内容,尽管某些插件可能直接使用 JDK 锁定 API。

于 2015-01-13T16:38:11.493 回答
0

我真的不知道出了什么问题,但我怀疑您的问题可能与类似。您是否在 NFS 挂载上使用您的项目和/或 sbt 副本和/或主目录进行构建?您是否尝试过完全从本地磁盘进行构建?

于 2014-02-23T07:30:01.247 回答