Vd A
Vd A

Reputation: 42

How do I get the "php artisan cache: clear" command to work?

I'm using a Mac. Can not execute the command

php artisan cache:clear

I get in return:

Failed to clear cache. Make sure you have the proper permissions.

This is for Laravel. Any ideas how to fix this?

Upvotes: 0

Views: 7606

Answers (3)

shijinmon Pallikal
shijinmon Pallikal

Reputation: 994

create storage/framework/cache/data directory manually.

Upvotes: 3

user10316640
user10316640

Reputation:

This could be one of several things(need more information to narrow it down):

  1. No cache files/records exist.(Updated to reflect your latest comments)
  2. If you are running a webserver (apache or ngix) as a different user, then you won't have permissions to the files as yourself.
  3. If you are using a cache driver other than file, like redis or database, make sure the credentials provided are correct.
  4. There could be a bug in the version of Laravel you are using; this would be unlikely.

Expansion on points 1 and 2:

  1. This is normal behavior. If you have opened pages expecting them to be cached and they are not, split the page and utilize @include directives splitting out the dynamic and static elements of the page into separate blade files.

  2. I like to add my user to the same group as the web server's group(www). Then change the group for all of the files to www, with group read permissions, and write permissions only on the bootstrap/cache and storage directories.

Upvotes: 2

George Hanson
George Hanson

Reputation: 3030

I think it might possibly be a bug with the latest version of Laravel, however unlikely it may seem. I started a new project today and installed a fresh copy of Laravel 5.7 and it seems to cause the error above. However, if I use 5.6 then the error does not appear.

Upvotes: 1

Related Questions