[英]gem install Errno::ENOLCK when installing gem
每當我嘗試使用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
我做gem install bundler
只是為了說明,但Errno :: ENOLCK將發生,無論我試圖安裝的gem。 我四處搜索,似乎無法找到有關此錯誤的任何內容。
這是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
在@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
有更多的進程訪問該文件,但我殺了它們並嘗試再次安裝,但我仍然遇到鎖定錯誤。 我也沒有超出磁盤空間。
以下是一些更多信息:這是在計算群集上。 主目錄/home/abod
在/ mnt上的某處/home/abod
鏈接,它安裝到網絡上的其他某台機器上。
一些評論者要求mount的輸出。 以下是有關主目錄的行:
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)
編輯我在rubygems github頁面上找到了與我的問題相關的這張票: https : //github.com/rubygems/rubygems/issues/1176
注意:我正在提供獎勵以幫助OP,因為我們需要更多專家幫助。
以下是一些讓您入門的一般性建議......
您是否可能沒有系統資源,例如磁盤空間?
或者您的系統限制了您可以使用的資源?
或者嘗試寫入您沒有權限的卷或鎖定守護程序?
如果沒有人能為您提供更好的答案,那么當您閱讀本文時,您是否可以嘗試運行這些命令,然后在您的問題中發布輸出?
$ 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
如果你想殺死訪問該文件的任何進程,那可能是持有鎖:
$ fuser --kill /home/abod/.gem/specs/api.rubygems.org%443/quick/Marshal.4.8/bundler-1.7.12.gemspec
你可以通過運行以下方法發現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)
}
如果上面的代碼失敗,那么最可能的解釋是您使用的文件系統不支持文件鎖定。 這與您的主目錄被安裝到其他一些文件系統是一致的,例如使用沒有鎖守護進程的NFS。
編輯:OP寫道:
運行您建議的代碼: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.gemspec (Errno::ENOLCK) from test.rb:4:in
blockflock': No locks available @ rb_file_flock - /home/abod/.gem/specs/api.rubygems.org%443/quick/Marshal.4.8/bundler-1.7.12.gemspec (Errno::ENOLCK) from test.rb:4:in
test.rb:3:inopen' from test.rb:3:in
'
在我看來,你的文件系統不提供鎖定。
我有兩個建議,我也在為你的問題增加一筆賞金,以吸引專家的注意力。
如果該計算機上的任何文件系統空間不是已裝入的計算群集,請嘗試在其中安裝gem。 您可以像這樣設置GEM_HOME
環境變量:
GEM_HOME=/foo/bar gem install <name>
如果您可以使用類似的系統,例如VirtualBox或VMWare上的相同操作系統,則可以使用bundler
gem, Gemfile
和命令bundle pack
。 這將創建一個充滿Gemfile中列出的gem的目錄。 然后,您可以將此目錄復制到任何您想要的位置,例如使用rsync,scp或sftp等。(這對於本機寶石沒有多大幫助,例如對於PostgreSQL的pg
- 您需要確保安裝你自己的所有PostgresSQL依賴項和標題)。
請您的系統管理員卸載並安裝分區; NFS Lock Daemon有時會搞砸,這會重置它。
(我知道,這不是一個優雅或長期的解決方案)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.