diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2017-01-23 17:49:37 -0600 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-01-23 21:06:41 -0600 |
commit | c8149f7e693660944b104b67f4aeb08b308f8c71 (patch) | |
tree | 66964e614fcd7e421c85c355de40763ff7f142e1 /lib | |
parent | 5a8ad746f4e560e8d7d6eded47e83ff99ac656b6 (diff) | |
download | bundler-c8149f7e693660944b104b67f4aeb08b308f8c71.tar.gz |
[Resolver] Restrict activated platforms to those in the Gemfileseg-resolver-restrict-platforms
This ensures that deps that come from the lockfile, which might only have the "ruby" platform, dont cause us to attempt to activate/resolve all "ruby" platform gems
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bundler/definition.rb | 2 | ||||
-rw-r--r-- | lib/bundler/resolver.rb | 11 |
2 files changed, 8 insertions, 5 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 1e13794ae7..85ee5a9ebf 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -249,7 +249,7 @@ module Bundler else # Run a resolve against the locally available gems Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}") - last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve) + last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms) end end end diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index 2eff76d7ff..ba569e3cdc 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -175,14 +175,15 @@ module Bundler # ==== Returns # <GemBundle>,nil:: If the list of dependencies can be resolved, a # collection of gemspecs is returned. Otherwise, nil is returned. - def self.resolve(requirements, index, source_requirements = {}, base = [], gem_version_promoter = GemVersionPromoter.new, additional_base_requirements = []) + def self.resolve(requirements, index, source_requirements = {}, base = [], gem_version_promoter = GemVersionPromoter.new, additional_base_requirements = [], platforms = nil) + platforms = Set.new(platforms) if platforms base = SpecSet.new(base) unless base.is_a?(SpecSet) - resolver = new(index, source_requirements, base, gem_version_promoter, additional_base_requirements) + resolver = new(index, source_requirements, base, gem_version_promoter, additional_base_requirements, platforms) result = resolver.start(requirements) SpecSet.new(result) end - def initialize(index, source_requirements, base, gem_version_promoter, additional_base_requirements) + def initialize(index, source_requirements, base, gem_version_promoter, additional_base_requirements, platforms) @index = index @source_requirements = source_requirements @base = base @@ -194,6 +195,7 @@ module Bundler @base_dg.add_vertex(ls.name, DepProxy.new(dep, ls.platform), true) end additional_base_requirements.each {|d| @base_dg.add_vertex(d.name, d) } + @platforms = platforms @gem_version_promoter = gem_version_promoter end @@ -308,7 +310,8 @@ module Bundler def requirement_satisfied_by?(requirement, activated, spec) return false unless requirement.matches_spec?(spec) || spec.source.is_a?(Source::Gemspec) - spec.activate_platform!(requirement.__platform) || spec.for?(requirement.__platform) + spec.activate_platform!(requirement.__platform) if !@platforms || @platforms.include?(requirement.__platform) + true end def sort_dependencies(dependencies, activated, conflicts) |