    # File lib/chef/knife/cookbook_site_install.rb, line 56
          def run
            extend Chef::Mixin::ShellOut

            if config[:cookbook_path]
              Chef::Config[:cookbook_path] = config[:cookbook_path]
            else
              config[:cookbook_path] = Chef::Config[:cookbook_path]
            end

            @cookbook_name = parse_name_args!
            # Check to ensure we have a valid source of cookbooks before continuing
            #
            @install_path = config[:cookbook_path].first
            ui.info "Installing #@cookbook_name to #{@install_path}"

            @repo = CookbookSCMRepo.new(@install_path, ui, config)
            #cookbook_path = File.join(vendor_path, name_args[0])
            upstream_file = File.join(@install_path, "#{@cookbook_name}.tar.gz")

            @repo.sanity_check
            @repo.reset_to_default_state
            @repo.prepare_to_import(@cookbook_name)

            downloader = download_cookbook_to(upstream_file)
            clear_existing_files(File.join(@install_path, @cookbook_name))
            extract_cookbook(upstream_file, @install_path)

            # TODO: it'd be better to store these outside the cookbook repo and
            # keep them around, e.g., in ~/Library/Caches on OS X.
            ui.info("removing downloaded tarball")
            shell_out!("rm #{upstream_file}", :cwd => vendor_path)

            if @repo.finalize_updates_to(@cookbook_name, downloader.version)
              @repo.reset_to_default_state
              @repo.merge_updates_from(@cookbook_name, downloader.version)
            else
              @repo.reset_to_default_state
            end

            unless config[:no_deps]
              md = Chef::Cookbook::Metadata.new
              md.from_file(File.join(@install_path, @cookbook_name, "metadata.rb"))
              md.dependencies.each do |cookbook, version_list|
                # Doesn't do versions.. yet
                nv = self.class.new
                nv.config = config
                nv.name_args = [ cookbook ]
                nv.run
              end
            end
          end