End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
Gem.write_binary
write_binary(path, data)
lib/rubygems.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.0.5/lib/rubygems.rb, line 802
def self.write_binary(path, data)
File.open(path, File::RDWR | File::CREAT | File::BINARY | File::LOCK_EX) do |io|
io.write data
end
rescue *WRITE_BINARY_ERRORS
File.open(path, 'wb') do |io|
io.write data
end
rescue Errno::ENOLCK # NFS
if Thread.main != Thread.current
raise
else
File.open(path, 'wb') do |io|
io.write data
end
end
end
Safely write a file in binary mode on all platforms.