Reapply "[rubygems/rubygems] Fix require of a default gem when unresolved gems depend on it"

This reverts commit 54552b89e73fc616ba47c1c87d33625af99cbce9.
This commit is contained in:
Hiroshi SHIBATA 2024-01-19 13:32:45 +09:00
parent 94af1e5b81
commit d51f4c9288
2 changed files with 22 additions and 0 deletions

View File

@ -62,6 +62,8 @@ module Kernel
Kernel.send(:gem, spec.name, Gem::Requirement.default_prerelease) unless
resolved_path
next
end
# If there are no unresolved deps, then we can use just try

View File

@ -540,6 +540,26 @@ class TestGemRequire < Gem::TestCase
assert_equal %w[default-3.0.0.rc2], loaded_spec_names
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
Gem.loaded_specs.values.map(&:full_name).sort
end