Skip to content

Commit

Permalink
[rubygems/rubygems] Fix incorrect force_ruby_platform propagation
Browse files Browse the repository at this point in the history
It was just working by chance.

(cherry picked from commit rubygems/rubygems@16b2d6bfe893)

rubygems/rubygems@8f922d980f
  • Loading branch information
deivid-rodriguez authored and matzbot committed Aug 2, 2022
1 parent 7cc5a65 commit ed9bbfd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
4 changes: 4 additions & 0 deletions lib/bundler/rubygems_ext.rb
Expand Up @@ -155,6 +155,10 @@ class Dependency

alias_method :eql?, :==

def force_ruby_platform
false
end

def encode_with(coder)
to_yaml_properties.each do |ivar|
coder[ivar.to_s.sub(/^@/, "")] = instance_variable_get(ivar)
Expand Down
19 changes: 10 additions & 9 deletions lib/bundler/spec_set.rb
Expand Up @@ -13,25 +13,27 @@ def initialize(specs)

def for(dependencies, check = false, platforms = [nil])
handled = ["bundler"].product(platforms).map {|k| [k, true] }.to_h
deps = dependencies.product(platforms).map {|dep, platform| [dep.name, platform && dep.force_ruby_platform ? Gem::Platform::RUBY : platform] }
deps = dependencies.product(platforms)
specs = []

loop do
break unless dep = deps.shift
next if handled.key?(dep)

handled[dep] = true
key = [dep[0].name, dep[1]]
next if handled.key?(key)

handled[key] = true

specs_for_dep = specs_for_dependency(*dep)
if specs_for_dep.any?
specs.concat(specs_for_dep)

specs_for_dep.first.dependencies.each do |d|
next if d.type == :development
deps << [d.name, dep[1]]
deps << [d, dep[1]]
end
elsif check
specs << IncompleteSpecification.new(*dep)
specs << IncompleteSpecification.new(*key)
end
end

Expand Down Expand Up @@ -175,13 +177,12 @@ def tsort_each_node
@specs.sort_by(&:name).each {|s| yield s }
end

def specs_for_dependency(name, platform)
specs_for_name = lookup[name]
def specs_for_dependency(dep, platform)
specs_for_name = lookup[dep.name]
if platform.nil?
GemHelpers.select_best_platform_match(specs_for_name.select {|s| Gem::Platform.match_spec?(s) }, Bundler.local_platform)
else
specs_for_name_and_platform = GemHelpers.select_best_platform_match(specs_for_name, platform)
specs_for_name_and_platform.any? ? specs_for_name_and_platform : specs_for_name
GemHelpers.select_best_platform_match(specs_for_name, dep.force_ruby_platform ? Gem::Platform::RUBY : platform)
end
end

Expand Down

0 comments on commit ed9bbfd

Please sign in to comment.