diff options
-rw-r--r-- | lib/bundler/resolver.rb | 37 | ||||
-rw-r--r-- | spec/resolver/platform_spec.rb | 19 | ||||
-rw-r--r-- | spec/support/indexes.rb | 4 |
3 files changed, 34 insertions, 26 deletions
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index 357d9a312a..2d0d63d557 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -150,33 +150,18 @@ module Bundler search.each do |sg| spec = sg.spec_for(platform) next if spec.nil? - spec_platform = spec.platform - if (platform != Gem::Platform::RUBY) || - (spec_platform && spec_platform != Gem::Platform::RUBY) - # Add a spec group for "non platform specific spec" as the fallback - # spec group. - sg_ruby = sg.copy_for(Gem::Platform::RUBY) - selected_sgs << sg_ruby if sg_ruby + # Add a spec group for "non platform specific spec" as the fallback + # spec group. + sg_ruby = sg.copy_for(Gem::Platform::RUBY) + selected_sgs << sg_ruby if sg_ruby + sg_all_platforms = sg.copy_for(platform) + activated_platforms = [platform] + @platforms.each do |other_platform| + next if platform == other_platform + sg_all_platforms.activate_platform!(other_platform) + activated_platforms << other_platform end - if platform != Gem::Platform::RUBY - # Add a spec group for ["non platform specific spec", "platform - # specific spec"] to resolve a spec for multiple platforms. - # If Gemfile.lock file has the following entries, we need a ffi-1.9.14 - # spec group for ["ruby", "x86-mingw32"]. - # - # GEM - # specs: - # ffi (1.9.14) - # ffi (1.9.14-x86-mingw32) - sg_ruby_platform = sg.copy_for(Gem::Platform::RUBY) - if sg_ruby_platform - sg_ruby_platform.activate_platform!(platform) - selected_sgs << sg_ruby_platform - end - end - sg_platform = sg.copy_for(platform) - sg_platform.activate_platform!(platform) - selected_sgs << sg_platform + selected_sgs << sg_all_platforms end selected_sgs end diff --git a/spec/resolver/platform_spec.rb b/spec/resolver/platform_spec.rb index 1f39e77117..5949abbecf 100644 --- a/spec/resolver/platform_spec.rb +++ b/spec/resolver/platform_spec.rb @@ -84,6 +84,25 @@ RSpec.describe "Resolving platform craziness" do should_resolve_as %w[foo-1.1.0] end + it "takes the latest ruby gem if the platform specific gem doesn't match the required_ruby_version with multiple platforms" do + @index = build_index do + gem "foo", "1.0.0" + gem "foo", "1.0.0", "x64-mingw32" + gem "foo", "1.1.0" do |s| + s.required_ruby_version = [">= 2.0"] + end + gem "foo", "1.1.0", "x64-mingw32" do |s| + s.required_ruby_version = [">= 2.0", "< 2.4"] + end + gem "Ruby\0", "2.5.1" + end + dep "foo" + dep "Ruby\0", "2.5.1" + platforms "x86_64-linux", "x64-mingw32" + + should_resolve_as %w[foo-1.1.0] + end + describe "with mingw32" do before :each do @index = build_index do diff --git a/spec/support/indexes.rb b/spec/support/indexes.rb index dc6e0bd1e9..7440523fc9 100644 --- a/spec/support/indexes.rb +++ b/spec/support/indexes.rb @@ -26,6 +26,10 @@ module Spec end end source_requirements ||= {} + args[0] ||= [] # base + args[1] ||= Bundler::GemVersionPromoter.new # gem_version_promoter + args[2] ||= [] # additional_base_requirements + args[3] ||= @platforms # platforms Bundler::Resolver.resolve(deps, @index, source_requirements, *args) end |