diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index d705e79998a..1c3c06abe5e 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -890,11 +890,12 @@ def concat_ruby_version_requirements(ruby_version, ruby_versions = []) end def expand_dependencies(dependencies, remote = false) + sorted_platforms = Resolver.sort_platforms(@platforms) deps = [] dependencies.each do |dep| dep = Dependency.new(dep, ">= 0") unless dep.respond_to?(:name) next if !remote && !dep.current_platform? - platforms = dep.gem_platforms(@platforms) + platforms = dep.gem_platforms(sorted_platforms) if platforms.empty? mapped_platforms = dep.platforms.map {|p| Dependency::PLATFORM_MAP[p] } Bundler.ui.warn \ @@ -904,7 +905,7 @@ def expand_dependencies(dependencies, remote = false) "To add those platforms to the bundle, " \ "run `bundle lock --add-platform #{mapped_platforms.join " "}`." end - Resolver.sort_platforms(platforms).each do |p| + platforms.each do |p| deps << DepProxy.new(dep, p) if remote || p == generic_local_platform end end diff --git a/lib/bundler/dependency.rb b/lib/bundler/dependency.rb index d2bac66cdb9..a96ba81a950 100644 --- a/lib/bundler/dependency.rb +++ b/lib/bundler/dependency.rb @@ -84,22 +84,19 @@ def initialize(name, version, options = {}, &blk) @groups = Array(options["group"] || :default).map(&:to_sym) @source = options["source"] @platforms = Array(options["platforms"]) + @gem_platforms = @platforms.map {|pl| PLATFORM_MAP[pl] }.compact.uniq @env = options["env"] @should_include = options.fetch("should_include", true) @autorequire = Array(options["require"] || []) if options.key?("require") end + # Returns the platforms this dependency is valid for, in the same order as + # passed in the `valid_platforms` parameter def gem_platforms(valid_platforms) return valid_platforms if @platforms.empty? - platforms = [] - @platforms.each do |p| - platform = PLATFORM_MAP[p] - next unless valid_platforms.include?(platform) - platforms |= [platform] - end - platforms + valid_platforms & @gem_platforms end def should_include?