diff --git a/lib/bundler/gem_helpers.rb b/lib/bundler/gem_helpers.rb index de007523ec..c27ceb360a 100644 --- a/lib/bundler/gem_helpers.rb +++ b/lib/bundler/gem_helpers.rb @@ -46,19 +46,21 @@ module Bundler end module_function :platform_specificity_match - def select_best_platform_match(specs, platform) - matching = specs.select {|spec| spec.match_platform(platform) } + def select_best_platform_match(specs, platform, force_ruby: false) + matching = if force_ruby + specs.select {|spec| spec.match_platform(Gem::Platform::RUBY) && spec.force_ruby_platform! } + else + specs.select {|spec| spec.match_platform(platform) } + end sort_best_platform_match(matching, platform) end module_function :select_best_platform_match - def force_ruby_platform(specs) - matching = specs.select {|spec| spec.match_platform(Gem::Platform::RUBY) && spec.force_ruby_platform! } - - sort_best_platform_match(matching, Gem::Platform::RUBY) + def select_best_local_platform_match(specs, force_ruby: false) + select_best_platform_match(specs, local_platform, force_ruby: force_ruby).map(&:materialize_for_installation).compact end - module_function :force_ruby_platform + module_function :select_best_local_platform_match def sort_best_platform_match(matching, platform) exact = matching.select {|spec| spec.platform == platform } diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb index 644d0f3866..5f513f3f22 100644 --- a/lib/bundler/spec_set.rb +++ b/lib/bundler/spec_set.rb @@ -277,13 +277,11 @@ module Bundler specs_for_name = lookup[dep.name] return [] unless specs_for_name - matching_specs = if dep.force_ruby_platform - GemHelpers.force_ruby_platform(specs_for_name) + if platform + GemHelpers.select_best_platform_match(specs_for_name, platform, force_ruby: dep.force_ruby_platform) else - GemHelpers.select_best_platform_match(specs_for_name, platform || Bundler.local_platform) + GemHelpers.select_best_local_platform_match(specs_for_name, force_ruby: dep.force_ruby_platform) end - matching_specs.map!(&:materialize_for_installation).compact! if platform.nil? - matching_specs end def tsort_each_child(s)