[rubygems/rubygems] Retry resolution with activated gems if inline has conflicts

https://github.com/rubygems/rubygems/commit/8d94c14ca0

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
This commit is contained in:
David Rodríguez 2022-05-13 14:50:30 +02:00 committed by git
parent 07fa9e3a8f
commit f8f9cecd70

View File

@ -60,8 +60,24 @@ def gemfile(install = false, options = {}, &gemfile)
end end
end end
runtime = Bundler::Runtime.new(nil, definition) begin
runtime.setup.require runtime = Bundler::Runtime.new(nil, definition).setup
rescue Gem::LoadError => e
name = e.name
version = e.requirement.requirements.first[1]
activated_version = Gem.loaded_specs[name].version
Bundler.ui.info \
"The #{name} gem was resolved to #{version}, but #{activated_version} was activated by Bundler while installing it, causing a conflict. " \
"Bundler will now retry resolving with #{activated_version} instead."
builder.instance_eval { gem name, activated_version }
definition = builder.to_definition(nil, true)
retry
end
runtime.require
end end
end end