ruby-changes:65451
From: Hiroshi <ko1@a...>
Date: Thu, 11 Mar 2021 17:25:16 +0900 (JST)
Subject: [ruby-changes:65451] 06cd5711e0 (ruby_3_0): Merge RubyGems-3.2.12 and Bundler-2.2.12
https://git.ruby-lang.org/ruby.git/commit/?id=06cd5711e0 From 06cd5711e0afc6302052e847863a7fdcc42fe692 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA <hsbt@r...> Date: Tue, 2 Mar 2021 20:38:16 +0900 Subject: Merge RubyGems-3.2.12 and Bundler-2.2.12 --- lib/bundler/definition.rb | 2 +- lib/bundler/installer.rb | 2 + lib/bundler/rubygems_gem_installer.rb | 47 ++++++++ lib/bundler/stub_specification.rb | 8 ++ lib/bundler/version.rb | 2 +- lib/rubygems.rb | 2 +- spec/bundler/bundler/dsl_spec.rb | 15 +-- spec/bundler/bundler/stub_specification_spec.rb | 27 +++++ spec/bundler/install/bundler_spec.rb | 4 +- spec/bundler/install/deploy_spec.rb | 14 ++- spec/bundler/install/gemfile/git_spec.rb | 2 - spec/bundler/install/gemfile/path_spec.rb | 4 - spec/bundler/install/gemfile/sources_spec.rb | 150 +++++++++++++++++++++--- spec/bundler/install/gems/resolving_spec.rb | 4 - spec/bundler/install/gemspecs_spec.rb | 2 - spec/bundler/other/major_deprecation_spec.rb | 58 ++++----- spec/bundler/runtime/inline_spec.rb | 4 - spec/bundler/support/matchers.rb | 27 +++-- 18 files changed, 282 insertions(+), 92 deletions(-) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 3c25149..3264cb0 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -594,7 +594,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L594 deps_for_source = @dependencies.select {|s| s.source == source } locked_deps_for_source = @locked_deps.values.select {|dep| dep.source == locked_source } - deps_for_source.sort != locked_deps_for_source.sort + deps_for_source.uniq.sort != locked_deps_for_source.sort end def specs_for_source_changed?(source) diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb index 8d55784..09c8b1c 100644 --- a/lib/bundler/installer.rb +++ b/lib/bundler/installer.rb @@ -89,6 +89,8 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/installer.rb#L89 end install(options) + Gem::Specification.reset # invalidate gem specification cache so that installed gems are immediately available + lock unless Bundler.frozen_bundle? Standalone.new(options[:standalone], @definition).generate if options[:standalone] end diff --git a/lib/bundler/rubygems_gem_installer.rb b/lib/bundler/rubygems_gem_installer.rb index cd5eb15..f5f3c53 100644 --- a/lib/bundler/rubygems_gem_installer.rb +++ b/lib/bundler/rubygems_gem_installer.rb @@ -8,6 +8,53 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/rubygems_gem_installer.rb#L8 # Bundler needs to install gems regardless of binstub overwriting end + def install + pre_install_checks + + run_pre_install_hooks + + spec.loaded_from = spec_file + + # Completely remove any previous gem files + FileUtils.rm_rf gem_dir + FileUtils.rm_rf spec.extension_dir + + FileUtils.mkdir_p gem_dir, :mode => 0o755 + + extract_files + + build_extensions + write_build_info_file + run_post_build_hooks + + generate_bin + generate_plugins + + write_spec + write_cache_file + + say spec.post_install_message unless spec.post_install_message.nil? + + run_post_install_hooks + + spec + end + + def generate_plugins + return unless Gem::Installer.instance_methods(false).include?(:generate_plugins) + + latest = Gem::Specification.stubs_for(spec.name).first + return if latest && latest.version > spec.version + + ensure_writable_dir @plugins_dir + + if spec.plugins.empty? + remove_plugins_for(spec, @plugins_dir) + else + regenerate_plugins_for(spec, @plugins_dir) + end + end + def pre_install_checks super && validate_bundler_checksum(options[:bundler_expected_checksum]) end diff --git a/lib/bundler/stub_specification.rb b/lib/bundler/stub_specification.rb index 2456d26..fa07190 100644 --- a/lib/bundler/stub_specification.rb +++ b/lib/bundler/stub_specification.rb @@ -26,11 +26,19 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/stub_specification.rb#L26 # @!group Stub Delegates + def manually_installed? + # This is for manually installed gems which are gems that were fixed in place after a + # failed installation. Once the issue was resolved, the user then manually created + # the gem specification using the instructions provided by `gem help install` + installed_by_version == Gem::Version.new(0) + end + # This is defined directly to avoid having to loading the full spec def missing_extensions? return false if default_gem? return false if extensions.empty? return false if File.exist? gem_build_complete_path + return false if manually_installed? true end diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb index 64c46dd..ef8a25a 100644 --- a/lib/bundler/version.rb +++ b/lib/bundler/version.rb @@ -1,7 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/lib/bundler/version.rb#L1 # frozen_string_literal: false module Bundler - VERSION = "2.2.11".freeze + VERSION = "2.2.12".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 d5f6356..c6c8063 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -8,7 +8,7 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems.rb#L8 require 'rbconfig' module Gem - VERSION = "3.2.11".freeze + VERSION = "3.2.12".freeze end # Must be first since it unloads the prelude from 1.9.2 diff --git a/spec/bundler/bundler/dsl_spec.rb b/spec/bundler/bundler/dsl_spec.rb index ff87b57..a47dd6e 100644 --- a/spec/bundler/bundler/dsl_spec.rb +++ b/spec/bundler/bundler/dsl_spec.rb @@ -25,7 +25,7 @@ RSpec.describe Bundler::Dsl do https://github.com/ruby/ruby/blob/trunk/spec/bundler/bundler/dsl_spec.rb#L25 expect { subject.git_source(:example) }.to raise_error(Bundler::InvalidOption) end - context "default hosts", :bundler => "2" do + context "default hosts", :bundler => "< 3" do it "converts :github to URI using https" do subject.gem("sparks", :github => "indirect/sparks") github_uri = "https://github.com/indirect/sparks.git" @@ -195,19 +195,6 @@ RSpec.describe Bundler::Dsl do https://github.com/ruby/ruby/blob/trunk/spec/bundler/bundler/dsl_spec.rb#L195 # gem 'spree_api' # gem 'spree_backend' # end - describe "#github", :bundler => "< 3" do - it "from github" do - spree_gems = %w[spree_core spree_api spree_backend] - subject.github "spree" do - spree_gems.each {|spree_gem| subject.send :gem, spree_gem } - end - - subject.dependencies.each do |d| - expect(d.source.uri).to eq("https://github.com/spree/spree.git") - end - end - end - describe "#github" do it "from github" do spree_gems = %w[spree_core spree_api spree_backend] diff --git a/spec/bundler/bundler/stub_specification_spec.rb b/spec/bundler/bundler/stub_specification_spec.rb index 0a54f9d..fb61281 100644 --- a/spec/bundler/bundler/stub_specification_spec.rb +++ b/spec/bundler/bundler/stub_specification_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Bundler::StubSpecification do https://github.com/ruby/ruby/blob/trunk/spec/bundler/bundler/stub_specification_spec.rb#L6 s.name = "gemname" s.version = "1.0.0" s.loaded_from = __FILE__ + s.extensions = "ext/gemname" end described_class.from_stub(gemspec) @@ -17,4 +18,30 @@ RSpec.describe Bundler::StubSpecification do https://github.com/ruby/ruby/blob/trunk/spec/bundler/bundler/stub_specification_spec.rb#L18 expect(stub).to be(with_bundler_stub_spec) end end + + describe "#manually_installed?" do + it "returns true if installed_by_version is nil or 0" do + stub = described_class.from_stub(with_bundler_stub_spec) + expect(stub.manually_installed?).to be true + end + + it "returns false if installed_by_version is greater than 0" do + stub = described_class.from_stub(with_bundler_stub_spec) + stub.installed_by_version = Gem::Version.new(1) + expect(stub.manually_installed?).to be false + end + end + + describe "#missing_extensions?" do + it "returns false if manually_installed?" do + stub = described_class.from_stub(with_bundler_stub_spec) + expect(stub.missing_extensions?).to be false + end + + it "returns true if not manually_installed?" do + stub = described_class.from_stub(with_bundler_stub_spec) + stub.installed_by_version = Gem::Version.new(1) + expect(stub.missing_extensions?).to be true + end + end end diff --git a/spec/bundler/install/bundler_spec.rb b/spec/bundler/install/bundler_spec.rb index 9445be6..963ce82 100644 --- a/spec/bundler/install/bundler_spec.rb +++ b/spec/bundler/install/bundler_spec.rb @@ -21,12 +21,12 @@ RSpec.describe "bundle install" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/install/bundler_spec.rb#L21 expect(the_bundle).to include_gems "bundler #{Bundler::VERSION}" end - it "are not added if not already present" do + it "are forced to the current bundler version even if not already present" do install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rack" G - expect(the_bundle).not_to include_gems "bundler #{Bundler::VERSION}" + expect(the_bundle).to include_gems "bundler #{Bundler::VERSION}" end it "causes a conflict if explicitly requesting a different version of bundler" do diff --git a/spec/bundler/install/deploy_spec.rb b (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/