diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2022-03-26 09:34:25 +0100 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2022-06-11 18:43:28 +0900 |
commit | 7f9eb888a3f86e286b5bc51705716b22ad02854c (patch) | |
tree | cf502bc09564edadea9d6d4ca041375e4b95117f /lib/bundler/source | |
parent | 965c314e34d05b196c8e079f868e79633076ad4c (diff) |
[rubygems/rubygems] Reuse package from the installer for extracting the specification
Previously we would instantiate two different packages and extract the
specification from the package twice for each gem installed. We can
reuse the installer for this so that we just need to do it once.
https://github.com/rubygems/rubygems/commit/e454f850b1
Diffstat (limited to 'lib/bundler/source')
-rw-r--r-- | lib/bundler/source/rubygems.rb | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index 3cb79667d8..f78e6a443b 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -155,27 +155,11 @@ module Bundler Installer.ambiguous_gems << [spec.name, *uris] if uris.length > 1 path = fetch_gem(spec, options[:previous_spec]) - begin - s = Bundler.rubygems.spec_from_gem(path, Bundler.settings["trust-policy"]) - rescue Gem::Security::Exception => e - raise SecurityError, - "The gem #{File.basename(path, ".gem")} can't be installed because " \ - "the security policy didn't allow it, with the message: #{e.message}" - rescue Gem::Package::FormatError - Bundler.rm_rf(path) - raise - end - - spec.__swap__(s) else path = cached_gem(spec) raise GemNotFound, "Could not find #{spec.file_name} for installation" unless path end - message = "Installing #{version_message(spec, options[:previous_spec])}" - message += " with native extensions" if spec.extensions.any? - Bundler.ui.confirm message - if requires_sudo? install_path = Bundler.tmp(spec.full_name) bin_path = install_path.join("bin") @@ -188,8 +172,9 @@ module Bundler require_relative "../rubygems_gem_installer" - installed_spec = Bundler::RubyGemsGemInstaller.at( + installer = Bundler::RubyGemsGemInstaller.at( path, + :security_policy => Bundler.rubygems.security_policies[Bundler.settings["trust-policy"]], :install_dir => install_path.to_s, :bin_dir => bin_path.to_s, :ignore_dependencies => true, @@ -198,7 +183,29 @@ module Bundler :build_args => options[:build_args], :bundler_expected_checksum => spec.respond_to?(:checksum) && spec.checksum, :bundler_extension_cache_path => extension_cache_path(spec) - ).install + ) + + if spec.remote + s = begin + installer.spec + rescue Gem::Package::FormatError + Bundler.rm_rf(path) + raise + rescue Gem::Security::Exception => e + raise SecurityError, + "The gem #{File.basename(path, ".gem")} can't be installed because " \ + "the security policy didn't allow it, with the message: #{e.message}" + end + + spec.__swap__(s) + end + + message = "Installing #{version_message(spec, options[:previous_spec])}" + message += " with native extensions" if spec.extensions.any? + Bundler.ui.confirm message + + installed_spec = installer.install + spec.full_gem_path = installed_spec.full_gem_path spec.loaded_from = installed_spec.loaded_from |