class Bundler::Resolver
def self.resolve(requirements, index, source_requirements = {})
==== Returns
*dependencies
==== Parameters
causing any gem activation errors.
the list of passed dependencies and any child dependencies without
Figures out the best possible configuration of gems that satisfies
def self.resolve(requirements, index, source_requirements = {}) resolver = new(index, source_requirements) result = catch(:success) do resolver.resolve(requirements, {}) output = resolver.errors.inject("") do |o, (conflict, (origin, requirement))| if origin o << " Conflict on: #{conflict.inspect}:\n" o << " * #{conflict} (#{origin.version}) activated by #{origin.required_by.first}\n" o << " * #{requirement} required by #{requirement.required_by.first}\n" else o << " #{requirement} not found in any of the sources\n" o << " required by #{requirement.required_by.first}\n" end o << " All possible versions of origin requirements conflict." end raise VersionConflict, "No compatible versions could be found for required dependencies:\n #{output}" nil end if result # Order gems in order of dependencies. Every gem's dependency is at # a smaller index in the array. ordered = [] result.values.each do |spec1| index = nil place = ordered.detect do |spec2| spec1.dependencies.any? { |d| d.name == spec2.name } end place ? ordered.insert(ordered.index(place), spec1) : ordered << spec1 end ordered.reverse end end