summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2024-10-09 09:13:49 +0200
committergit <svn-admin@ruby-lang.org>2024-10-11 09:42:08 +0000
commitaad4bfd7bc1170394fcedf1997d644f8374ad7b0 (patch)
tree5d922a7ddfb4232f20e7818e041c04d5bdf7b708
parent01abc2f79e770df5e6cc75a4610f4831ff0b5bf3 (diff)
[rubygems/rubygems] Fix `gem install` on NFS shares
NFS shares seem to support flock these days, but they need read-write permissions. https://github.com/rubygems/rubygems/commit/1c492804cd
-rw-r--r--lib/bundler/rubygems_ext.rb5
-rw-r--r--lib/rubygems.rb5
2 files changed, 4 insertions, 6 deletions
diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb
index 14f10af9d7..547102be41 100644
--- a/lib/bundler/rubygems_ext.rb
+++ b/lib/bundler/rubygems_ext.rb
@@ -36,15 +36,14 @@ module Gem
remove_method :open_file_with_flock if Gem.respond_to?(:open_file_with_flock)
def open_file_with_flock(path, &block)
- mode = IO::RDONLY | IO::APPEND | IO::CREAT | IO::BINARY
+ # read-write mode is used rather than read-only in order to support NFS
+ mode = IO::RDWR | IO::APPEND | IO::CREAT | IO::BINARY
mode |= IO::SHARE_DELETE if IO.const_defined?(:SHARE_DELETE)
File.open(path, mode) do |io|
begin
io.flock(File::LOCK_EX)
rescue Errno::ENOSYS, Errno::ENOTSUP
- rescue Errno::ENOLCK # NFS
- raise unless Thread.main == Thread.current
end
yield io
end
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 43c0d8f13c..8c3e8bdc68 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -808,15 +808,14 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# Open a file with given flags, and protect access with flock
def self.open_file_with_flock(path, &block)
- mode = IO::RDONLY | IO::APPEND | IO::CREAT | IO::BINARY
+ # read-write mode is used rather than read-only in order to support NFS
+ mode = IO::RDWR | IO::APPEND | IO::CREAT | IO::BINARY
mode |= IO::SHARE_DELETE if IO.const_defined?(:SHARE_DELETE)
File.open(path, mode) do |io|
begin
io.flock(File::LOCK_EX)
rescue Errno::ENOSYS, Errno::ENOTSUP
- rescue Errno::ENOLCK # NFS
- raise unless Thread.main == Thread.current
end
yield io
end