2013-07-16 32 views
3

建设火花项目,我试图使用sbt。下列异常发生:“没有锁可用”当运行sbt cmd

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 我ASLO试图改变SBT启动目录,以避免权限问题。

任何想法,我做错了。

回答

0

我真的不知道什么是错,但我怀疑你的问题可能类似于this one。你正在用你的项目和/或你的sbt和/或你的主目录拷贝到NFS挂载上吗?你有没有尝试完全从本地磁盘构建?

2

SBT依赖于你的JVM的财产“的user.home”作为工作目录,并似乎获取锁在里面,如果你的“的user.home”指向一个NFS目录当中没有安装NFS锁服务,然后你会得到“无锁可用”的错误。

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

  • 安装NFS锁服务
  • 泰尔SBT不使用你的NFS目录,通过性能-Duser.home = /路径/中/本地/磁盘。例如。
    • sbt clean compile -Duser.home=/disk1/myhome
+0

是的,我们尝试获取〜/ .ivy2 /中的锁,以确保只有一个进程正在触摸常青藤缓存,以避免我们所遇到的腐败问题。 你可以禁用它。 – jsuereth

+0

感谢您的通知。我认为获得锁定以避免腐败对我来说是必要的,而maven无论如何都会在$ HOME中获得锁定,所以我只使用本地$ HOME。不幸的是,我公司的集群没有NFS锁... – zhaown

1

默认SBT试图启动或做相关性解析时,需要一个独占锁。这是为了避免高速缓存损坏,或删除另一个进程正在使用的JAR文件(这可能会导致一些非常奇怪的错误)。

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

你应该能够通过禁用此锁定:

sbt -Dsbt.boot.lock=false 

Addtionally,如果你有自己的sbt.boot.properties文件,你需要以下条件:

[boot] 
lock: false 

这将禁用内部锁定功能该启动程序依次禁用所有使用此功能的sbt项目的锁定。 AFAIK这意味着sbt中的所有内容,尽管一些插件可能直接使用JDK锁定API。