# File lib/rubygems/dependency_installer.rb, line 101
  def find_gems_with_sources(dep)
    gems_and_sources = []

    if @domain == :both or @domain == :local then
      Dir[File.join(Dir.pwd, "#{dep.name}-[0-9]*.gem")].each do |gem_file|
        spec = Gem::Format.from_file_by_path(gem_file).spec
        gems_and_sources << [spec, gem_file] if spec.name == dep.name
      end
    end

    if @domain == :both or @domain == :remote then
      gems_and_sources.push(*Gem::SourceInfoCache.search_with_source(dep, true))
    end

    gems_and_sources.sort_by do |gem, source|
      [gem, source !~ /^http:\/\// ? 1 : 0] # local gems win
    end
  end