ruby-changes:55028
From: nagachika <ko1@a...>
Date: Wed, 13 Mar 2019 06:45:00 +0900 (JST)
Subject: [ruby-changes:55028] nagachika:r67235 (ruby_2_5): Merge RubyGems 2.7.6.2 patch [Bug #15643]
nagachika 2019-03-13 06:44:56 +0900 (Wed, 13 Mar 2019) New Revision: 67235 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67235 Log: Merge RubyGems 2.7.6.2 patch [Bug #15643] Modified files: branches/ruby_2_5/lib/rubygems/bundler_version_finder.rb branches/ruby_2_5/lib/rubygems.rb branches/ruby_2_5/test/rubygems/test_gem.rb branches/ruby_2_5/test/rubygems/test_gem_bundler_version_finder.rb branches/ruby_2_5/test/rubygems/test_gem_dependency.rb branches/ruby_2_5/version.h Index: ruby_2_5/lib/rubygems/bundler_version_finder.rb =================================================================== --- ruby_2_5/lib/rubygems/bundler_version_finder.rb (revision 67234) +++ ruby_2_5/lib/rubygems/bundler_version_finder.rb (revision 67235) @@ -1,12 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_5/lib/rubygems/bundler_version_finder.rb#L1 module Gem::BundlerVersionFinder - @without_filtering = false - - def self.without_filtering - without_filtering, @without_filtering = true, @without_filtering - yield - ensure - @without_filtering = without_filtering - end def self.bundler_version version, _ = bundler_version_with_reason @@ -17,8 +9,6 @@ module Gem::BundlerVersionFinder https://github.com/ruby/ruby/blob/trunk/ruby_2_5/lib/rubygems/bundler_version_finder.rb#L9 end def self.bundler_version_with_reason - return if @without_filtering - if v = ENV["BUNDLER_VERSION"] return [v, "`$BUNDLER_VERSION`"] end @@ -36,7 +26,7 @@ module Gem::BundlerVersionFinder https://github.com/ruby/ruby/blob/trunk/ruby_2_5/lib/rubygems/bundler_version_finder.rb#L26 return unless vr = bundler_version_with_reason <<-EOS Could not find 'bundler' (#{vr.first}) required by #{vr.last}. -To update to the lastest version installed on your system, run `bundle update --bundler`. +To update to the latest version installed on your system, run `bundle update --bundler`. To install the missing version, run `gem install bundler:#{vr.first}` EOS end @@ -44,20 +34,14 @@ To install the missing version, run `gem https://github.com/ruby/ruby/blob/trunk/ruby_2_5/lib/rubygems/bundler_version_finder.rb#L34 def self.compatible?(spec) return true unless spec.name == "bundler".freeze return true unless bundler_version = self.bundler_version - if bundler_version.segments.first >= 2 - spec.version == bundler_version - else # 1.x - spec.version.segments.first < 2 - end + + spec.version.segments.first == bundler_version.segments.first end def self.filter!(specs) return unless bundler_version = self.bundler_version - if bundler_version.segments.first >= 2 - specs.reject! { |spec| spec.version != bundler_version } - else # 1.x - specs.reject! { |spec| spec.version.segments.first >= 2} - end + + specs.reject! { |spec| spec.version.segments.first != bundler_version.segments.first } end def self.bundle_update_bundler_version Index: ruby_2_5/lib/rubygems.rb =================================================================== --- ruby_2_5/lib/rubygems.rb (revision 67234) +++ ruby_2_5/lib/rubygems.rb (revision 67235) @@ -10,7 +10,7 @@ require 'rbconfig' https://github.com/ruby/ruby/blob/trunk/ruby_2_5/lib/rubygems.rb#L10 require 'thread' module Gem - VERSION = "2.7.6.1" + VERSION = "2.7.6.2" end # Must be first since it unloads the prelude from 1.9.2 @@ -270,12 +270,7 @@ module Gem https://github.com/ruby/ruby/blob/trunk/ruby_2_5/lib/rubygems.rb#L270 return loaded if loaded && dep.matches_spec?(loaded) - find_specs = proc { dep.matching_specs(true) } - if dep.to_s == "bundler (>= 0.a)" - specs = Gem::BundlerVersionFinder.without_filtering(&find_specs) - else - specs = find_specs.call - end + specs = dep.matching_specs(true) specs = specs.find_all { |spec| spec.executables.include? exec_name Index: ruby_2_5/version.h =================================================================== --- ruby_2_5/version.h (revision 67234) +++ ruby_2_5/version.h (revision 67235) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_5/version.h#L1 #define RUBY_VERSION "2.5.4" #define RUBY_RELEASE_DATE "2019-03-13" -#define RUBY_PATCHLEVEL 147 +#define RUBY_PATCHLEVEL 148 #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 3 Index: ruby_2_5/test/rubygems/test_gem_dependency.rb =================================================================== --- ruby_2_5/test/rubygems/test_gem_dependency.rb (revision 67234) +++ ruby_2_5/test/rubygems/test_gem_dependency.rb (revision 67235) @@ -358,7 +358,7 @@ class TestGemDependency < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_5/test/rubygems/test_gem_dependency.rb#L358 dep.to_specs end - assert_match "Could not find 'bundler' (3.5) required by reason.\nTo update to the lastest version installed on your system, run `bundle update --bundler`.\nTo install the missing version, run `gem install bundler:3.5`\n", e.message + assert_match "Could not find 'bundler' (3.5) required by reason.\nTo update to the latest version installed on your system, run `bundle update --bundler`.\nTo install the missing version, run `gem install bundler:3.5`\n", e.message end Gem::BundlerVersionFinder.stub(:bundler_version_with_reason, ["2.0.0.pre.1", "reason"]) do Index: ruby_2_5/test/rubygems/test_gem_bundler_version_finder.rb =================================================================== --- ruby_2_5/test/rubygems/test_gem_bundler_version_finder.rb (revision 67234) +++ ruby_2_5/test/rubygems/test_gem_bundler_version_finder.rb (revision 67235) @@ -88,20 +88,21 @@ class TestGemBundlerVersionFinder < Gem: https://github.com/ruby/ruby/blob/trunk/ruby_2_5/test/rubygems/test_gem_bundler_version_finder.rb#L88 bvf.stub(:bundler_version, v("2.1.1.1")) do assert bvf.compatible?(util_spec("foo")) assert bvf.compatible?(util_spec("bundler", "2.1.1.1")) - refute bvf.compatible?(util_spec("bundler", "2.1.1.a")) + assert bvf.compatible?(util_spec("bundler", "2.1.1.a")) + assert bvf.compatible?(util_spec("bundler", "2.999")) refute bvf.compatible?(util_spec("bundler", "1.999")) - refute bvf.compatible?(util_spec("bundler", "2.999")) + refute bvf.compatible?(util_spec("bundler", "3.0.0")) end end def test_filter - versions = %w[1 1.0 1.0.1.1 2.a 3 3.0] + versions = %w[1 1.0 1.0.1.1 2 2.a 2.0 2.1.1 3 3.a 3.0 3.1.1] specs = versions.map { |v| util_spec("bundler", v) } - assert_equal %w[1 1.0 1.0.1.1 2.a 3 3.0], util_filter_specs(specs).map(&:version).map(&:to_s) + assert_equal %w[1 1.0 1.0.1.1 2 2.a 2.0 2.1.1 3 3.a 3.0 3.1.1], util_filter_specs(specs).map(&:version).map(&:to_s) bvf.stub(:bundler_version, v("2.1.1.1")) do - assert_empty util_filter_specs(specs).map(&:version).map(&:to_s) + assert_equal %w[2 2.a 2.0 2.1.1], util_filter_specs(specs).map(&:version).map(&:to_s) end bvf.stub(:bundler_version, v("1.1.1.1")) do assert_equal %w[1 1.0 1.0.1.1], util_filter_specs(specs).map(&:version).map(&:to_s) @@ -110,10 +111,10 @@ class TestGemBundlerVersionFinder < Gem: https://github.com/ruby/ruby/blob/trunk/ruby_2_5/test/rubygems/test_gem_bundler_version_finder.rb#L111 assert_equal %w[1 1.0 1.0.1.1], util_filter_specs(specs).map(&:version).map(&:to_s) end bvf.stub(:bundler_version, v("2.a")) do - assert_equal %w[2.a], util_filter_specs(specs).map(&:version).map(&:to_s) + assert_equal %w[2 2.a 2.0 2.1.1], util_filter_specs(specs).map(&:version).map(&:to_s) end bvf.stub(:bundler_version, v("3")) do - assert_equal %w[3 3.0], util_filter_specs(specs).map(&:version).map(&:to_s) + assert_equal %w[3 3.a 3.0 3.1.1], util_filter_specs(specs).map(&:version).map(&:to_s) end end Index: ruby_2_5/test/rubygems/test_gem.rb =================================================================== --- ruby_2_5/test/rubygems/test_gem.rb (revision 67234) +++ ruby_2_5/test/rubygems/test_gem.rb (revision 67235) @@ -209,6 +209,41 @@ class TestGem < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_5/test/rubygems/test_gem.rb#L209 assert_equal %w(a-1 b-2 c-1), loaded_spec_names end + def test_activate_bin_path_gives_proper_error_for_bundler + bundler = util_spec 'bundler', '2' do |s| + s.executables = ['bundle'] + end + + install_specs bundler + + File.open("Gemfile.lock", "w") do |f| + f.write <<-L.gsub(/ {8}/, "") + GEM + remote: https://rubygems.org/ + specs: + + PLATFORMS + ruby + + DEPENDENCIES + + BUNDLED WITH + 9999 + L + end + + File.open("Gemfile", "w") { |f| f.puts('source "https://rubygems.org"') } + + e = assert_raises Gem::GemNotFoundException do + load Gem.activate_bin_path("bundler", "bundle", ">= 0.a") + end + + assert_includes e.message, "Could not find 'bundler' (9999) required by your #{File.expand_path("Gemfile.lock")}." + assert_includes e.message, "To update to the latest version installed on your system, run `bundle update --bundler`." + assert_includes e.message, "To install the missing version, run `gem install bundler:9999`" + refute_includes e.message, "can't find gem bundler (>= 0.a) with executable bundle" + end + def test_self_bin_path_no_exec_name e = assert_raises ArgumentError do Gem.bin_path 'a' -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/