summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2021-12-24 09:32:59 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2021-12-24 10:35:31 +0900
commitb0ad6cb371747a04eb12580e74c73179173cc89d (patch)
treeee873d5c682c4665c838e3ea43585536229a5509 /lib
parentde0523feddf740d28fe772f3a22ff9907f88bf69 (diff)
Merge RubyGems-3.3.2 and Bundler-2.3.2
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5334
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/definition.rb5
-rw-r--r--lib/bundler/version.rb2
-rw-r--r--lib/rubygems.rb54
-rw-r--r--lib/rubygems/exceptions.rb10
-rw-r--r--lib/rubygems/specification.rb2
-rw-r--r--lib/rubygems/stub_specification.rb2
6 files changed, 34 insertions, 41 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 9a94bd3ed3..5cde1285a6 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -292,10 +292,7 @@ module Bundler
locked_major = @locked_bundler_version.segments.first
current_major = Gem::Version.create(Bundler::VERSION).segments.first
- if updating_major = locked_major < current_major
- Bundler.ui.warn "Warning: the lockfile is being updated to Bundler #{current_major}, " \
- "after which you will be unable to return to Bundler #{locked_major}."
- end
+ updating_major = locked_major < current_major
end
preserve_unknown_sections ||= !updating_major && (Bundler.frozen_bundle? || !(unlocking? || @unlocking_bundler))
diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb
index bfe7ae7f7c..a7ccc9c201 100644
--- a/lib/bundler/version.rb
+++ b/lib/bundler/version.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
module Bundler
- VERSION = "2.3.1".freeze
+ VERSION = "2.3.2".freeze
def self.bundler_major_version
@bundler_major_version ||= VERSION.split(".").first.to_i
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 2e13c589b3..762ecdf857 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -8,7 +8,7 @@
require 'rbconfig'
module Gem
- VERSION = "3.3.1".freeze
+ VERSION = "3.3.2".freeze
end
# Must be first since it unloads the prelude from 1.9.2
@@ -163,16 +163,6 @@ module Gem
specifications/default
].freeze
- ##
- # Exception classes used in a Gem.read_binary +rescue+ statement
-
- READ_BINARY_ERRORS = [Errno::EACCES, Errno::EROFS, Errno::ENOSYS, Errno::ENOTSUP].freeze
-
- ##
- # Exception classes used in Gem.write_binary +rescue+ statement
-
- WRITE_BINARY_ERRORS = [Errno::ENOSYS, Errno::ENOTSUP].freeze
-
@@win_platform = nil
@configuration = nil
@@ -776,40 +766,42 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# Safely read a file in binary mode on all platforms.
def self.read_binary(path)
- File.open path, 'rb+' do |f|
- f.flock(File::LOCK_EX)
- f.read
- end
- rescue *READ_BINARY_ERRORS
- File.open path, 'rb' do |f|
- f.read
+ open_with_flock(path, 'rb+') do |io|
+ io.read
end
- rescue Errno::ENOLCK # NFS
- if Thread.main != Thread.current
- raise
- else
- File.open path, 'rb' do |f|
- f.read
- end
+ rescue Errno::EACCES, Errno::EROFS
+ open_with_flock(path, 'rb') do |io|
+ io.read
end
end
##
# Safely write a file in binary mode on all platforms.
def self.write_binary(path, data)
- File.open(path, File::RDWR | File::CREAT | File::LOCK_EX, binmode: true) do |io|
+ open_with_flock(path, 'wb') do |io|
io.write data
end
- rescue *WRITE_BINARY_ERRORS
- File.open(path, 'wb') do |io|
- io.write data
+ end
+
+ ##
+ # Open a file with given flags, and protect access with flock
+
+ def self.open_with_flock(path, flags, &block)
+ File.open(path, flags) do |io|
+ unless java_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, 'wb') do |io|
- io.write data
+ File.open(path, flags) do |io|
+ yield io
end
end
end
diff --git a/lib/rubygems/exceptions.rb b/lib/rubygems/exceptions.rb
index 20e4049e48..1806869098 100644
--- a/lib/rubygems/exceptions.rb
+++ b/lib/rubygems/exceptions.rb
@@ -24,10 +24,14 @@ class Gem::UnknownCommandError < Gem::Exception
return if defined?(@attached)
if defined?(DidYouMean::SPELL_CHECKERS) && defined?(DidYouMean::Correctable)
- DidYouMean::SPELL_CHECKERS['Gem::UnknownCommandError'] =
- Gem::UnknownCommandSpellChecker
+ if DidYouMean.respond_to?(:correct_error)
+ DidYouMean.correct_error(Gem::UnknownCommandError, Gem::UnknownCommandSpellChecker)
+ else
+ DidYouMean::SPELL_CHECKERS['Gem::UnknownCommandError'] =
+ Gem::UnknownCommandSpellChecker
- prepend DidYouMean::Correctable
+ prepend DidYouMean::Correctable
+ end
end
@attached = true
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index f162eb4a84..031a37f775 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -1116,7 +1116,7 @@ class Gem::Specification < Gem::BasicSpecification
file = file.dup.tap(&Gem::UNTAINT)
return unless File.file?(file)
- code = File.read file, :mode => 'r:UTF-8:-'
+ code = Gem.open_with_flock(file, 'r:UTF-8:-', &:read)
code.tap(&Gem::UNTAINT)
diff --git a/lib/rubygems/stub_specification.rb b/lib/rubygems/stub_specification.rb
index 4246f9de86..47fe7da695 100644
--- a/lib/rubygems/stub_specification.rb
+++ b/lib/rubygems/stub_specification.rb
@@ -110,7 +110,7 @@ class Gem::StubSpecification < Gem::BasicSpecification
begin
saved_lineno = $.
- File.open loaded_from, OPEN_MODE do |file|
+ Gem.open_with_flock loaded_from, OPEN_MODE do |file|
begin
file.readline # discard encoding line
stubline = file.readline.chomp