[rubygems/rubygems] Fix require
of a default gem when unresolved gems depend on it
The following conditions must be met: * A default gem is required. * A previous require left some gems unresolved, and those dependencies themselves depend on the default gem. In this case, rubygems require will first activate the default version of the gem, then try to activate another unresolved version of the default gem that conflicts with the first activation. The solution is, if we are in the middle of requiring a default gem, skip this step, because we have already activated it successfully. https://github.com/rubygems/rubygems/commit/8cd5608db5 Co-authored-by: Stan Hu <stanhu@gmail.com>
This commit is contained in:
parent
8044e57907
commit
f1f5f22d22
@ -62,6 +62,8 @@ module Kernel
|
|||||||
|
|
||||||
Kernel.send(:gem, spec.name, Gem::Requirement.default_prerelease) unless
|
Kernel.send(:gem, spec.name, Gem::Requirement.default_prerelease) unless
|
||||||
resolved_path
|
resolved_path
|
||||||
|
|
||||||
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
# If there are no unresolved deps, then we can use just try
|
# If there are no unresolved deps, then we can use just try
|
||||||
|
@ -540,6 +540,26 @@ class TestGemRequire < Gem::TestCase
|
|||||||
assert_equal %w[default-3.0.0.rc2], loaded_spec_names
|
assert_equal %w[default-3.0.0.rc2], loaded_spec_names
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_default_gem_with_unresolved_gems_depending_on_it
|
||||||
|
net_http_old = util_spec "net-http", "0.1.1", nil, "lib/net/http.rb"
|
||||||
|
install_gem net_http_old
|
||||||
|
|
||||||
|
net_http_default = new_default_spec "net-http", "0.3.0", nil, "net/http.rb"
|
||||||
|
install_default_gems net_http_default
|
||||||
|
|
||||||
|
faraday_1 = util_spec "faraday", "1", { "net-http" => ">= 0" }
|
||||||
|
install_gem faraday_1
|
||||||
|
|
||||||
|
faraday_2 = util_spec "faraday", "2", { "net-http" => ">= 0" }
|
||||||
|
install_gem faraday_2
|
||||||
|
|
||||||
|
chef = util_spec "chef", "1", { "faraday" => [">= 1", "< 3"] }, "lib/chef.rb"
|
||||||
|
install_gem chef
|
||||||
|
|
||||||
|
assert_require "chef"
|
||||||
|
assert_require "net/http"
|
||||||
|
end
|
||||||
|
|
||||||
def loaded_spec_names
|
def loaded_spec_names
|
||||||
Gem.loaded_specs.values.map(&:full_name).sort
|
Gem.loaded_specs.values.map(&:full_name).sort
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user