diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2022-07-13 14:37:17 +0900 |
---|---|---|
committer | nagachika <nagachika@ruby-lang.org> | 2022-09-03 15:54:07 +0900 |
commit | b9f6a09bd2127ea51612bd27bef5830831b48d4f (patch) | |
tree | 2ea33c0d2c14e86b1b0ad7449d85ec068d954aea /lib/rubygems | |
parent | d7862a5de43f7412ab41cdae6709c8a30b988621 (diff) |
Merge RubyGems-3.3.15 and Bundler-2.3.15
Diffstat (limited to 'lib/rubygems')
-rw-r--r-- | lib/rubygems/command_manager.rb | 7 | ||||
-rw-r--r-- | lib/rubygems/commands/update_command.rb | 9 | ||||
-rw-r--r-- | lib/rubygems/specification.rb | 14 |
3 files changed, 18 insertions, 12 deletions
diff --git a/lib/rubygems/command_manager.rb b/lib/rubygems/command_manager.rb index 03cdd6a4bb..e421f89884 100644 --- a/lib/rubygems/command_manager.rb +++ b/lib/rubygems/command_manager.rb @@ -148,7 +148,12 @@ class Gem::CommandManager def run(args, build_args=nil) process_args(args, build_args) rescue StandardError, Timeout::Error => ex - alert_error clean_text("While executing gem ... (#{ex.class})\n #{ex}") + if ex.respond_to?(:detailed_message) + msg = ex.detailed_message(highlight: false).sub(/\A(.*?)(?: \(.+?\))/) { $1 } + else + msg = ex.message + end + alert_error clean_text("While executing gem ... (#{ex.class})\n #{msg}") ui.backtrace ex terminate_interaction(1) diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb index 42d6f6046b..54b1251010 100644 --- a/lib/rubygems/commands/update_command.rb +++ b/lib/rubygems/commands/update_command.rb @@ -173,10 +173,11 @@ command to remove old versions. highest_remote_gem.first end - def install_rubygems(version) # :nodoc: + def install_rubygems(spec) # :nodoc: args = update_rubygems_arguments + version = spec.version - update_dir = File.join Gem.dir, 'gems', "rubygems-update-#{version}" + update_dir = File.join spec.base_dir, 'gems', "rubygems-update-#{version}" Dir.chdir update_dir do say "Installing RubyGems #{version}" unless options[:silent] @@ -290,9 +291,7 @@ command to remove old versions. installed_gems = update_gem('rubygems-update', version) if installed_gems.empty? || installed_gems.first.version != version return if installed_gems.empty? - version = installed_gems.first.version - - install_rubygems version + install_rubygems installed_gems.first end def update_rubygems_arguments # :nodoc: diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index 9b533caf54..33eb0a2bff 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -1270,7 +1270,14 @@ class Gem::Specification < Gem::BasicSpecification def self._load(str) Gem.load_yaml - array = Marshal.load str + array = begin + Marshal.load str + rescue ArgumentError => e + raise unless e.message.include?("YAML") + + Object.const_set "YAML", Psych + Marshal.load str + end spec = Gem::Specification.new spec.instance_variable_set :@specification_version, array[1] @@ -1289,11 +1296,6 @@ class Gem::Specification < Gem::BasicSpecification raise TypeError, "invalid Gem::Specification format #{array.inspect}" end - # Cleanup any Psych::PrivateType. They only show up for an old bug - # where nil => null, so just convert them to nil based on the type. - - array.map! {|e| e.kind_of?(Psych::PrivateType) ? nil : e } - spec.instance_variable_set :@rubygems_version, array[0] # spec version spec.instance_variable_set :@name, array[2] |