# File lib/rubygems/installer.rb, line 177
  def install
    # If we're forcing the install then disable security unless the security
    # policy says that we only install singed gems.
    @security_policy = nil if @force and @security_policy and
                              not @security_policy.only_signed

    unless @force then
      if rrv = @spec.required_ruby_version then
        unless rrv.satisfied_by? Gem.ruby_version then
          raise Gem::InstallError, "#{@spec.name} requires Ruby version #{rrv}"
        end
      end

      if rrgv = @spec.required_rubygems_version then
        unless rrgv.satisfied_by? Gem::Version.new(Gem::RubyGemsVersion) then
          raise Gem::InstallError,
                "#{@spec.name} requires RubyGems version #{rrgv}"
        end
      end

      unless @ignore_dependencies then
        deps = @spec.runtime_dependencies
        deps |= @spec.development_dependencies if @development

        deps.each do |dep_gem|
          ensure_dependency @spec, dep_gem
        end
      end
    end

    Gem.pre_install_hooks.each do |hook|
      hook.call self
    end

    FileUtils.mkdir_p @gem_home unless File.directory? @gem_home

    Gem.ensure_gem_subdirectories @gem_home

    FileUtils.mkdir_p @gem_dir

    extract_files
    generate_bin
    build_extensions
    write_spec

    # HACK remove?  Isn't this done in multiple places?
    cached_gem = File.join @gem_home, "cache", @gem.split(/\//).pop
    unless File.exist? cached_gem then
      FileUtils.cp @gem, File.join(@gem_home, "cache")
    end

    say @spec.post_install_message unless @spec.post_install_message.nil?

    @spec.loaded_from = File.join(@gem_home, 'specifications',
                                  "#{@spec.full_name}.gemspec")

    @source_index.add_spec @spec

    Gem.post_install_hooks.each do |hook|
      hook.call self
    end

    return @spec
  rescue Zlib::GzipFile::Error
    raise Gem::InstallError, "gzip error installing #{@gem}"
  end