New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[L5.7] Cache clear fails #25451

Closed
moharrum opened this Issue Sep 5, 2018 · 24 comments

Comments

Projects
None yet
@moharrum
Copy link

moharrum commented Sep 5, 2018

  • 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
@sisve

This comment has been minimized.

Copy link
Contributor

sisve commented Sep 5, 2018

What cache driver are you using, and do you have the appropriate permissions?

@ferdikam

This comment has been minimized.

Copy link

ferdikam commented Sep 5, 2018

Hi,
I too have the same problem after a new installation of laravel.

@moharrum

This comment has been minimized.

Copy link
Author

moharrum commented Sep 5, 2018

My cache drive is file.
storage/framework/cache permissions: drwxrwxr-x

@khaledelmahdi

This comment has been minimized.

Copy link

khaledelmahdi commented Sep 6, 2018

Same here on Mac...

@AegirLeet

This comment has been minimized.

Copy link

AegirLeet commented Sep 6, 2018

The "data" directory (storage/framework/cache/data) doesn't exist by default, which causes the check at

if (! $this->files->isDirectory($this->directory)) {
return false;
}
to fail and return false, which in turn causes
if (! $successful) {
return $this->error('Failed to clear cache. Make sure you have the appropriate permissions.');
}
to error out.

@billrobclark

This comment has been minimized.

Copy link

billrobclark commented Sep 8, 2018

I have this issue as well after upgrading to 5.7

@m-lotze

This comment has been minimized.

Copy link

m-lotze commented Sep 10, 2018

php artisan cache:clear works fine for me, but with any option it doesnt.
php artisan cache:clear --tags=views fails with the message Failed 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.

@AegirLeet

This comment has been minimized.

Copy link

AegirLeet commented Sep 10, 2018

When using redis with tags, the error is caused at

public function flush()
{
$this->deleteForeverKeys();
$this->deleteStandardKeys();
parent::flush();
}

This method should return a bool, but returns nothing, which evaluates to false and triggers the error.
Cache clearing should still work fine, but the cache:cleared event won't fire.

Also, when using the DB store,

public function flush()
{
return (bool) $this->table()->delete();
}
will return false if the cache table is already empty, leading to the same kind of misleading error message.

@alkapatel

This comment has been minimized.

Copy link

alkapatel commented Sep 12, 2018

same cache problem here, how can solve it?

@AegirLeet

This comment has been minimized.

Copy link

AegirLeet commented Sep 12, 2018

@alkapatel If you're using the file store driver, create the storage/framework/cache/data directory manually.

@elias-alea

This comment has been minimized.

Copy link

elias-alea commented Sep 25, 2018

@taylorotwell closed this but a fresh install of laravel 5.7 today gave me this same issue. What am I missing?

@tramel-woodard

This comment has been minimized.

Copy link

tramel-woodard commented Sep 26, 2018

@taylorotwell same here

@phannaly

This comment has been minimized.

Copy link
Contributor

phannaly commented Sep 26, 2018

@tramel-woodard , @elias-alea you need to create storage/framework/cache/data directory manually like @AegirLeet said.

@elias-alea

This comment has been minimized.

Copy link

elias-alea commented Sep 27, 2018

@tramel-woodard , @elias-alea you need to create storage/framework/cache/data directory manually like @AegirLeet said.

Thanks loads. Quick question, how do I know which solutions to trust? The ones closed by contributors?
Also, I think this information could be added to the documentation here: https://laravel.com/docs/5.7/cache#configuration

Thanks

@phannaly

This comment has been minimized.

Copy link
Contributor

phannaly commented Sep 27, 2018

@elias-alea If you install laravel now, you will get storage/framework/cache/data directory automatically so you don't have to create it. They leave this directory to allow the filesystem to cache.

@elias-alea

This comment has been minimized.

Copy link

elias-alea commented Sep 27, 2018

@phannaly noted, awesome!
@taylorotwell and team, thanks loads, you are the men!

mfn added a commit to mfn/docs that referenced this issue Sep 27, 2018

@mfn

This comment has been minimized.

Copy link
Contributor

mfn commented Sep 27, 2018

The upgrade guide has now a reference to the missing data/ directory (section "Cache")

@haroloe

This comment has been minimized.

Copy link

haroloe commented Oct 6, 2018

SI, al agregar esta carpeta data, este problema queda solucionado, Muchas Gracias

@gabriel9944

This comment has been minimized.

Copy link

gabriel9944 commented Oct 16, 2018

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 luego
cp storage/framework/cache/.gitignore storage/framework/cache/data/.gitignore
y listo ya esta con esto

@mitulvc

This comment has been minimized.

Copy link

mitulvc commented Oct 26, 2018

Thanks @gabriel9944

@markdark09

This comment has been minimized.

Copy link

markdark09 commented Nov 3, 2018

Just only add folder name "data" in storage/framework/cache/ and try php artisan cache:clear.

@phpguru

This comment has been minimized.

Copy link
Contributor

phpguru commented Dec 21, 2018

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:clear just create these folders if they don't exist but are required for the framework to operate?

@alterman1994

This comment has been minimized.

Copy link

alterman1994 commented Jan 9, 2019

the same issue, however, the "storage/framework/cache/data" folder exists.
[laravel]$ php artisan cache:clear
Failed to clear cache. Make sure you have the appropriate permissions.

Laravel Framework 5.7.18
PHP 7.2.13
10.1.37-MariaDB

any suggestions?

@phpguru

This comment has been minimized.

Copy link
Contributor

phpguru commented Jan 10, 2019

@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-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment