# File lib/rubygems/commands/unpack_command.rb, line 70
  def get_path(gemname, version_req)
    return gemname if gemname =~ /\.gem$/i

    specs = Gem::source_index.find_name gemname, version_req

    selected = specs.sort_by { |s| s.version }.last

    return nil if selected.nil?

    # We expect to find (basename).gem in the 'cache' directory.
    # Furthermore, the name match must be exact (ignoring case).
    if gemname =~ /^#{selected.name}$/i
      filename = selected.full_name + '.gem'
      path = nil

      Gem.path.find do |gem_dir|
        path = File.join gem_dir, 'cache', filename
        File.exist? path
      end

      path
    else
      nil
    end
  end