diff options
author | David RodrÃguez <[email protected]> | 2024-01-11 21:53:26 +0100 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2024-01-19 11:28:11 +0900 |
commit | f1f5f22d22a149f20e019728b1ab35593d29d81a (patch) | |
tree | 2007719038a6c427f1142d01914404f46a6ea670 /test | |
parent | 8044e57907bc5a066ca9ef309d90c62906f8e2ec (diff) |
[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 <[email protected]>
Diffstat (limited to 'test')
-rw-r--r-- | test/rubygems/test_require.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb index b3926afe15..7f5584ea8a 100644 --- a/test/rubygems/test_require.rb +++ b/test/rubygems/test_require.rb @@ -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 |