framework: [L5.7] Cache clear fails
- Laravel Version: 5.7.1
- PHP Version: 7.2.9
- Database Driver & Version: MariaDB 10.2.16.
Description:
Attempting to clear app cache returns an error message:
Failed to clear cache. Make sure you have the appropriate permissions.
Steps To Reproduce:
$ php artisan cache:clear
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 27
- Comments: 32 (11 by maintainers)
The “data” directory (storage/framework/cache/data) doesn’t exist by default, which causes the check at https://github.com/laravel/framework/blob/9c844aa37617d8694ba364e16a5f26ecc470c18e/src/Illuminate/Cache/FileStore.php#L144-L146 to fail and return false, which in turn causes https://github.com/laravel/framework/blob/9c844aa37617d8694ba364e16a5f26ecc470c18e/src/Illuminate/Cache/Console/ClearCommand.php#L71-L73 to error out.
@alkapatel If you’re using the file store driver, create the storage/framework/cache/data directory manually.
@tramel-woodard , @elias-alea you need to create
storage/framework/cache/datadirectory manually like @AegirLeet said.For me
php artisan cache:clearcommand worked after
php artisan config:cachecommand. It worked 😕
Use this package, It will tackle all cache and clean it properly.
https://github.com/rakshitbharat/cleanify
I don’t understand why I am directed to read the documentation and/or upgrade guide when the framework could just as easily (re)create folders, particularly cache file locations, that it requires to exist, if they aren’t present. The fact that Laravel developers need several empty folders to exist in the repository with a .gitignore only is kind of silly. Why doesn’t
php artisan cache:clearjust create these folders if they don’t exist but are required for the framework to operate?por los que aun tienen el problema del cache yo lo solucione como dice la guia de instalacion, use lo siguiente:
mkdir -p storage/framework/cache/data;y luegocp storage/framework/cache/.gitignore storage/framework/cache/data/.gitignorey listo ya esta con esto@alterman1994 I would chown it and/or chmod it (recursively) if needed, to the user running artisan command. If it got created by www-data, it can give permissions issue when running as logged in user. On our servers (Ubuntu) we add ubuntu, root, www-data to www-group and chown group ownership to www-group. HTH-
Just only add folder name “data” in storage/framework/cache/ and try php artisan cache:clear.
The upgrade guide has now a reference to the missing
data/directory (section “Cache”)@elias-alea If you install laravel now, you will get
storage/framework/cache/datadirectory automatically so you don’t have to create it. They leave this directory to allow the filesystem to cache.This solved issue for me 😃
Laracasts source via @bobbybouwmann
@taylorotwell closed this but a fresh install of laravel 5.7 today gave me this same issue. What am I missing?
php artisan cache:clearworks fine for me, but with any option it doesnt.php artisan cache:clear --tags=viewsfails with the messageFailed to clear cache. Make sure you have the appropriate permissions.Tried adding the data directory, but that does not help.I am using redis for all caches.