Bug #15643 ยป rubygems-2.7.6.2.patch
lib/rubygems.rb | ||
---|---|---|
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
|
||
... | ... | |
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
|
lib/rubygems/bundler_version_finder.rb | ||
---|---|---|
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
|
||
... | ... | |
end
|
||
def self.bundler_version_with_reason
|
||
return if @without_filtering
|
||
if v = ENV["BUNDLER_VERSION"]
|
||
return [v, "`$BUNDLER_VERSION`"]
|
||
end
|
||
... | ... | |
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
|
||
... | ... | |
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
|
test/rubygems/test_gem.rb | ||
---|---|---|
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'
|
test/rubygems/test_gem_bundler_version_finder.rb | ||
---|---|---|
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)
|
||
... | ... | |
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
|
||
test/rubygems/test_gem_dependency.rb | ||
---|---|---|
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
|