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