# File lib/rubygems/dependency_installer.rb, line 132
  def gather_dependencies
    specs = @specs_and_sources.map { |spec,_| spec }

    # these gems were listed by the user, always install them
    keep_names = specs.map { |spec| spec.full_name }

    dependency_list = Gem::DependencyList.new @development
    dependency_list.add(*specs)
    to_do = specs.dup

    add_found_dependencies to_do, dependency_list unless @ignore_dependencies

    dependency_list.specs.reject! { |spec|
      not keep_names.include?(spec.full_name) and
      Gem::Specification.include?(spec)
    }

    unless dependency_list.ok? or @ignore_dependencies or @force then
      reason = dependency_list.why_not_ok?.map { |k,v|
        "#{k} requires #{v.join(", ")}"
      }.join("; ")
      raise Gem::DependencyError, "Unable to resolve dependencies: #{reason}"
    end

    @gems_to_install = dependency_list.dependency_order.reverse
  end