Revert "[rubygems/rubygems] Fix activation conflicts when circularly requiring a gem"
This reverts commit db44088c2a92040879386aa5f268db4c858e4e5b. https://github.com/ruby/ruby/actions/runs/7578672002/job/20641640821 https://github.com/ruby/ruby/actions/runs/7578672002/job/20641641212 https://github.com/ruby/ruby/actions/runs/7578672002/job/20641642031
This commit is contained in:
parent
7265a5be01
commit
04cf66765a
@ -1216,13 +1216,6 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
|||||||
##
|
##
|
||||||
# Find a Gem::Specification of default gem from +path+
|
# Find a Gem::Specification of default gem from +path+
|
||||||
|
|
||||||
def find_default_spec(path)
|
|
||||||
@path_to_default_spec_map[path]
|
|
||||||
end
|
|
||||||
|
|
||||||
##
|
|
||||||
# Find an unresolved Gem::Specification of default gem from +path+
|
|
||||||
|
|
||||||
def find_unresolved_default_spec(path)
|
def find_unresolved_default_spec(path)
|
||||||
default_spec = @path_to_default_spec_map[path]
|
default_spec = @path_to_default_spec_map[path]
|
||||||
default_spec if default_spec && loaded_specs[default_spec.name] != default_spec
|
default_spec if default_spec && loaded_specs[default_spec.name] != default_spec
|
||||||
|
@ -42,11 +42,7 @@ module Kernel
|
|||||||
# If +path+ belongs to a default gem, we activate it and then go straight
|
# If +path+ belongs to a default gem, we activate it and then go straight
|
||||||
# to normal require
|
# to normal require
|
||||||
|
|
||||||
if spec = Gem.find_default_spec(path)
|
if spec = Gem.find_unresolved_default_spec(path)
|
||||||
name = spec.name
|
|
||||||
|
|
||||||
next if Gem.loaded_specs[name]
|
|
||||||
|
|
||||||
# Ensure -I beats a default gem
|
# Ensure -I beats a default gem
|
||||||
resolved_path = begin
|
resolved_path = begin
|
||||||
rp = nil
|
rp = nil
|
||||||
@ -64,7 +60,7 @@ module Kernel
|
|||||||
rp
|
rp
|
||||||
end
|
end
|
||||||
|
|
||||||
Kernel.send(:gem, name, Gem::Requirement.default_prerelease) unless
|
Kernel.send(:gem, spec.name, Gem::Requirement.default_prerelease) unless
|
||||||
resolved_path
|
resolved_path
|
||||||
|
|
||||||
next
|
next
|
||||||
|
@ -560,45 +560,6 @@ class TestGemRequire < Gem::TestCase
|
|||||||
assert_require "net/http"
|
assert_require "net/http"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_default_gem_required_circulary_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"
|
|
||||||
net_http_default_path = File.join(@tempdir, "default_gems", "lib", "net/http.rb")
|
|
||||||
install_default_gems net_http_default
|
|
||||||
File.write(net_http_default_path, 'require "net/http"')
|
|
||||||
|
|
||||||
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"
|
|
||||||
|
|
||||||
out, err = capture_output do
|
|
||||||
assert_require "net/http"
|
|
||||||
end
|
|
||||||
|
|
||||||
assert_empty out
|
|
||||||
|
|
||||||
circular_require_warning = false
|
|
||||||
|
|
||||||
err_lines = err.split("\n").reject do |line|
|
|
||||||
if line.include?("circular require")
|
|
||||||
circular_require_warning = true
|
|
||||||
elsif circular_require_warning # ignore backtrace lines for circular require warning
|
|
||||||
circular_require_warning = line.start_with?(/[\s]/)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
assert_empty err_lines
|
|
||||||
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