'Please provide a valid cache path error in Laravel 9

I'm working with Jetstream library with Laravel 9, And I've deleted the storage folder by the wrong, and then it shows the following error.

Please provide a valid cache path.

What should I do? I tried the command composer install, and I faced the same error! So how can I return back to the storage folder?



Solution 1:[1]

create the following

storage/app
storage/app/public
storage/framework
storage/framework/cache
storage/framework/cache/data
storage/framework/views
storage/framework/session
storage/logs

And use git to manage your code so that accidents like this are easily recovered

Solution 2:[2]

  1. Open your terminal.
  2. Run cd YOUR_LARAVEL_PATH to navigate to the Laravel directory.
  3. Run mkdir storage/framework/{cache,sessions,views} to create missing directories.
  4. Run php artisan cache:clear
  5. Run php artisan config:clear
  6. Run php artisan view:clear
  7. Run chmod -R 777 storage to set write permissions (depends on your system).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Snapey
Solution 2 NickSdot