Posts Learn Components Snippets Categories Tags Tools About
/

How to Fix "Please Provide a Valid Cache Path" error in Laravel

Learn how to fix "Please Provide a Valid Cache Path" error in Laravel

Created on Jul 21, 2021

3123 views

In this snippet, you'll learn how to fix "Please Provide a Valid Cache Path" in Laravel and this is a common error when you are manually setting up to deploy your Laravel application to VPS/cloud.

The Cause of Error
This error it's caused by the missing "storage/framework" directory and its respective sub directories. Because of this, the application will throw an error saying "Please provide a valid cache path".

The Fix to the Error
The fix to this error is to have the following directories inside the "storage" folder.
framework
framework/cache 
framework/sessions 
framework/views

The path is as follows.
/path/to/laravel/storage/framework/

Step 1 - Create Missing Directory
To create the missing directory you can SSH to the server and create the storage with the command line. Do note that it's assumed you are in the root directory of your Laravel application.
cd storage
mkdir -p framework/{sessions,views,cache}

The command below will create the 3 sub-directory "session", "views" and "cache" inside the framework directory.

Step 2 - Set Directory Permission
Finally set the directory permission to allow write to the directory.
chmod -R 777 framework
chown -R www-data:www-data framework

Step 3 - Run Link Storage Command 
The final step is to run "php artisan storage:link" command and this will link your "storage" directory with the "/public/storage" directory.
php artisan storage:link

You might also need to clear the cache in Laravel to clean up any existing cache.

If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️

)