I had an issue on my Windows workstation with Drupal 7.15 and Drush 5.2 or 5.7 when clearing the cache for all 17 sites at the same time. But I think this also occurred on my Linux production server, but cannot check that right now.
When trying to clear the cache using drush @sites cache-clear all, the folder C:\Users\USERNAME/.drush/cache/default/ keeps being created and removed, since I see it flashing by in explorer.
Sometimes the result was (say in 50% of the cases):
'all' cache was cleared in C:/drupal#SITENAME
but sometimes it was:
file_put_contents(C:\Users\USERNAME/.drush/cache/default/5.7-commandfiles-5-360407b77294ab6be6b70c5e54073079.cache): failed to open stream: No such file or directory cache.inc:433 [warning]
Drush seemed to have problems with the writing of a file, so I wrote the following directory check for function DrushJSONCache::writeFile(), situated in cache.inc, and it worked.
/**
* JSON cache storage backend.
*/
class DrushJSONCache extends DrushFileCache {
const EXTENSION = '.json';
function readFile($filename) {
$item = file_get_contents($filename);
return $item ? (object)drush_json_decode($item) : FALSE;
}
function writeFile($filename, $cache) {
$dirname = dirname($filename); // <- added line
if (!is_dir($dirname)) mkdir($dirname, 0777, true); // <- added line
return file_put_contents($filename, drush_json_encode($cache));
}
}
Comments
Comment #1
moshe weitzman commentedComment #2
moshe weitzman commentedComment #3
lmeurs commentedI can confirm this happened on my Linux production server as well, the additional two lines fixed this for me. (Drupal 7.15, Drush 5.2)
But it also seems that when a site's cache cannot be cleared, Drush does not remove the site from the queue until it has successfully cleared the site's cache. Some sites give no warnings, others 1 or even 2, but eventually they all have success.
Comment #4
moshe weitzman commentedChange to Mark as this sounds broader than Windows
Comment #5
fonant commentedConfirm that I have the same problem (Linux box, Drush 5.6) for "drush @sites cc all". The two lines added as above to create the @.drush/cache/default@ directory work to fix the error here.
It appears that Drush removes the @.drush/cache/default@ directory when it has finished (perhaps only for a multi-site command?) although there is an empty @.drush/cache/usage@ directory remaining.
The 0777 permissions might possibly be better being a bit more restrictive, depending on who many different users (current shell user only, I presume) need access to the cache. Although since it appears to be deleted anyway, perhaps this isn't a worry.
Comment #6
msonnabaum commentedThis sounds like the bug that Owen just fixed. Please try again with the latest from master.
Comment #7
lmeurs commentedI just updated to Drush v5.8 and ran
drush @sites cache-clear all8 times in a row on the same Windows 7 workstation with 22 sites installed on it. The problem does not occur anymore, but 2 times I got the following warning:Comment #8
greg.1.anderson commentedThis issue was marked
closed (won't fix)because Drush has moved to Github.If desired, you may copy this bug to our Github project and then post a link here to the new issue. Please also change the status of this issue to
closed (duplicate).Please ask support questions on Drupal Answers.
Comment #8.0
greg.1.anderson commentedTried to make clearer that it only happens when clearing cache for all 17 sites, AT THE SAME TIME