I was working on a search server recently and started getting errors that the crawl component was failing to “CreateTempFolderForCacheFiles”

As it turns out, the environment I was working on was an extremely secure farm where permissions were locked down and often shares were not permitted and accounts were allowed the minimum permissions they needed in order to run.  In  this case, the local temporary folder where the index files are created had been deleted, and the search service did not have permissions to recreate the folder.  This was blocking the crawls from proceeding and they were just sitting there.

In order to fix the issue, the folders need to be recreated.  What is nice is that using PowerShell you can quickly recreate the folders in the correct location using the following script:

$app = Get-SPEnterpriseSearchServiceApplication "<my SSA>"
$crawlComponents = Get-SPEnterpriseSearchCrawlComponent -CrawlTopology $app.CrawlTopologies.ActiveTopology | where {$_.ServerName.ToLower().Equals($Env:COMPUTERNAME.ToLower()) }
foreach ($component in $crawlComponents)
{
    $path = $component.IndexLocation + "\" + $component.Name
    if ( Test-Path $path -pathType container)
    {
        Write-Host "Directory " $path " already exists"
    }
    Else
    {
        Write-Host "Creating Directory: " $path
        New-Item $path -ItemType directory | write-output
    }
}