End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
Gem.open_file
open_file(path, flags) { |io| ... }
lib/rubygems.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.1.3/lib/rubygems.rb, line 782
def self.open_file(path, flags, &block)
File.open(path, flags) do |io|
if !java_platform? && win_platform?
begin
io.flock(File::LOCK_EX)
rescue Errno::ENOSYS, Errno::ENOTSUP
end
end
yield io
end
rescue Errno::ENOLCK # NFS
if Thread.main != Thread.current
raise
else
File.open(path, flags) do |io|
yield io
end
end
end
Open a file with given flags, and on Windows protect access with flock
See also
.needs
.operating_system_defaults
.marshal_version
.path
also in
4.1 · 4.0 · 3.4 · 3.3 · 3.2