简体   繁体   English

gem安装时安装Errno :: ENOLCK

[英]gem install Errno::ENOLCK when installing gem

Whenever I try to install a gem with gem install [gem-name] , I keep getting this error: 每当我尝试使用gem install [gem-name] ,我都会收到此错误:

ERROR:  While executing gem ... (Errno::ENOLCK)
    No locks available @ rb_file_flock - /home/abod/.gem/specs/api.rubygems.org%443/quick/Marshal.4.8/bundler-1.7.12.gemspec

I did gem install bundler just for illustration, but the Errno::ENOLCK will occur regardless of the gem I'm trying to install. 我做gem install bundler只是为了说明,但Errno :: ENOLCK将发生,无论我试图安装的gem。 I've searched around and can't seem to find anything about this error. 我四处搜索,似乎无法找到有关此错误的任何内容。

Here is the out put from gem env , in case that helps. 这是gem env ,如果有帮助的话。

RubyGems Environment:
  - RUBYGEMS VERSION: 2.4.5
  - RUBY VERSION: 2.2.0 (2014-12-25 patchlevel 0) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/abod/.rvm/gems/ruby-2.2.0@global
  - RUBY EXECUTABLE: /home/abod/.rvm/rubies/ruby-2.2.0/bin/ruby
  - EXECUTABLE DIRECTORY: /home/abod/.rvm/gems/ruby-2.2.0@global/bin
  - SPEC CACHE DIRECTORY: /home/abod/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /home/abod/.rvm/rubies/ruby-2.2.0/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/abod/.rvm/gems/ruby-2.2.0@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /home/abod/.rvm/gems/ruby-2.2.0@global/bin
     - /home/abod/.rvm/rubies/ruby-2.2.0/bin
     - /usr/local/bin
     - /usr/bin
     - /usr/local/sbin
     - /usr/sbin
     - /home/abod/.rvm/bin
     - /home/abod/.rvm/bin

At the suggestion of @joelparkerhenderson, here are the output of some commands that may be helpful. 在@joelparkerhenderson的建议下,这里是一些可能有用的命令的输出。

$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 2063389
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 32768
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 2063389
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited


$ uname -a
Linux biohen36 3.14.23-100.fc19.x86_64 #1 SMP Thu Oct 30 18:36:00 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

$ stat /home/abod/.gem/specs/api.rubygems.org%443/quick/Marshal.4.8/bundler-1.7.12.gemspec
  File: ‘/home/abod/.gem/specs/api.rubygems.org%443/quick/Marshal.4.8/bundler-1.7.12.gemspec’
  Size: 1025        Blocks: 8          IO Block: 1048576 regular file
Device: 2fh/47d Inode: 2285894     Links: 1
Access: (0644/-rw-r--r--)  Uid: (  730/    abod)   Gid: ( 1013/ wommack)
Access: 2015-02-03 01:12:35.573192019 -0500
Modify: 2015-02-02 13:53:41.227813208 -0500
Change: 2015-02-02 13:53:41.227813208 -0500
 Birth: -

$ fuser -m /home/abod/.gem/specs/api.rubygems.org%443/quick/Marshal.4.8/bundler-1.7.12.gemspec
/home/abod/.gem/specs/api.rubygems.org%443/quick/Marshal.4.8/bundler-1.7.12.gemspec: 57788c

There were more processes accessing the file, but I killed them and tried to install again, but I still got the lock error. 有更多的进程访问该文件,但我杀了它们并尝试再次安装,但我仍然遇到锁定错误。 I'm not out of disk space either. 我也没有超出磁盘空间。

Here is some more info: This is on a compute cluster. 以下是一些更多信息:这是在计算群集上。 The home directory /home/abod is symlinked somewhere on /mnt which mounts to some other machine on the network. 主目录/home/abod在/ mnt上的某处/home/abod链接,它安装到网络上的其他某台机器上。

The output from mount has been requested by a few commenters. 一些评论者要求mount的输出。 Here are the lines regarding the home directory: 以下是有关主目录的行:

fileserver:/homes on /home type nfs (rw,noatime,nodiratime,vers=3,rsize=1048576,wsize=1048576,namlen=255,soft,nocto,noacl,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=128.175.xxx.xxx,mountvers=3,mountport=20048,mountproto=udp,local_lock=none,addr=128.175.xxx.xxx)
-hosts on /net/fileserver/homes type autofs (rw,relatime,fd=13,pgrp=1368,timeout=300,minproto=5,maxproto=5,offset)
fileserver:/homes on /net/fileserver/homes type nfs (rw,nosuid,nodev,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=128.175.xxx.xxx,mountvers=3,mountport=20048,mountproto=udp,local_lock=none,addr=128.175.xxx.xxx)

Edit I found this ticket on the rubygems github page that is related to my issue: https://github.com/rubygems/rubygems/issues/1176 编辑我在rubygems github页面上找到了与我的问题相关的这张票: https//github.com/rubygems/rubygems/issues/1176

Note: I'm offering a bounty to help the OP, because we need more expert help. 注意:我正在提供奖励以帮助OP,因为我们需要更多专家帮助。

Here are some general ideas to get you started... 以下是一些让您入门的一般性建议......

  • Is it possible that you're out of system resources, such as disk space? 您是否可能没有系统资源,例如磁盘空间?

  • Or your system is limiting the resources you can use? 或者您的系统限制了您可以使用的资源?

  • Or trying to write to a volume where you don't have permissions or a lock daemon? 或者尝试写入您没有权限的卷或锁定守护程序?

If no one has a better answer for you, by the time you read this, can you try running these commands then post the output in your question? 如果没有人能为您提供更好的答案,那么当您阅读本文时,您是否可以尝试运行这些命令,然后在您的问题中发布输出?

$ df

$ ulimit -a

$ uname -a

$ stat /home/abod/.gem/specs/api.rubygems.org%443/quick/Marshal.4.8/bundler-1.7.12.gemspec

$ fuser -m /home/abod/.gem/specs/api.rubygems.org%443/quick/Marshal.4.8/bundler-1.7.12.gemspec

If you want to kill any process accessing that file, that may be holding locks: 如果你想杀死访问该文件的任何进程,那可能是持有锁:

$ fuser --kill /home/abod/.gem/specs/api.rubygems.org%443/quick/Marshal.4.8/bundler-1.7.12.gemspec

You can discover if the issue is with Ruby vs. gem by running this: 你可以通过运行以下方法发现Ruby与gem之间是否存在问题:

path = "/home/abod/.gem/specs/api.rubygems.org%443/quick/Marshal.4.8/bundler-1.7.12.gemspec"
f = File.open(path, File::RDWR|File::CREAT, 0644){|f|
  f.flock(File::LOCK_EX)
  f.flock(File::LOCK_UN)
}

If the above code fails, then the most likely explanation is that you're using a filesystem that doesn't support file locking. 如果上面的代码失败,那么最可能的解释是您使用的文件系统不支持文件锁定。 This would be consistent with your home directory being mounted to some other filesystem, such as using NFS without a lock daemon. 这与您的主目录被安装到其他一些文件系统是一致的,例如使用没有锁守护进程的NFS。

Edit: OP writes: 编辑:OP写道:

Running the code you suggest: test.rb:4:in flock': No locks available @ rb_file_flock - /home/abod/.gem/specs/api.rubygems.org%443/quick/Marshal.4.8/bundler-1.7.12.gems‌​pec (Errno::ENOLCK) from test.rb:4:in block in ' from test.rb:3:in open' from test.rb:3:in ' 运行您建议的代码:test.rb:4:in flock': No locks available @ rb_file_flock - /home/abod/.gem/specs/api.rubygems.org%443/quick/Marshal.4.8/bundler-1.7.12.gems‌​pec (Errno::ENOLCK) from test.rb:4:in block flock': No locks available @ rb_file_flock - /home/abod/.gem/specs/api.rubygems.org%443/quick/Marshal.4.8/bundler-1.7.12.gems‌​pec (Errno::ENOLCK) from test.rb:4:in test.rb:3:in open' from test.rb:3:in '

That looks to me like your filesystem doesn't provide locking. 在我看来,你的文件系统不提供锁定。

I have two suggestions and I'm also adding a bounty to your question to help attract expert attention. 我有两个建议,我也在为你的问题增加一笔赏金,以吸引专家的注意力。

  • If you have any filesystem space on that computer that isn't a mounted compute cluster, try installing a gem there. 如果该计算机上的任何文件系统空间不是已装入的计算群集,请尝试在其中安装gem。 You can set the GEM_HOME environment variable like this: 您可以像这样设置GEM_HOME环境变量:

     GEM_HOME=/foo/bar gem install <name> 
  • If you can use a similar system, such as the same OS on VirtualBox or VMWare, then you can use the bundler gem, a Gemfile , and the command bundle pack . 如果您可以使用类似的系统,例如VirtualBox或VMWare上的相同操作系统,则可以使用bundler gem, Gemfile和命令bundle pack This creates a directory full of the gems listed in the Gemfile. 这将创建一个充满Gemfile中列出的gem的目录。 You can then copy this directory anywhere you want, for example by using rsync, or scp, or sftp, etc. (This doesn't help much though with native gems, such as pg for PostgreSQL - you would need to be sure to install all the PostgresSQL dependencies and headers on your own). 然后,您可以将此目录复制到任何您想要的位置,例如使用rsync,scp或sftp等。(这对于本机宝石没有多大帮助,例如对于PostgreSQL的pg - 您需要确保安装你自己的所有PostgresSQL依赖项和标题)。

Ask your Sys Admin to unmount and mount the partition; 请您的系统管理员卸载并安装分区; the NFS Lock Daemon messes up at times and this will reset it. NFS Lock Daemon有时会搞砸,这会重置它。

(Not exactly an elegant or long-term solution, I know). (我知道,这不是一个优雅或长期的解决方案)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM