Laravel throws 'The bootstrap/cache directory must be present and writable' error after update

Stefan Izdrail

Founder & Senior Architect · 2026-06-29

Laravel Company
Title: Tackling 'The bootstrap/cache directory must be present and writable' Error in Laravel After Updates Body: Laravel is an efficient PHP framework that simplifies web app development. However, it isn't immune to issues during updates. One such error you might encounter is "Exception in ProviderRepository.php line 190: The bootstrap/cache directory must be present and writable." This can seem confusing, especially when the website works perfectly after each 'composer update,' only for the issue to resurface at a later time. To solve this problem, you need to understand how Laravel uses cache and why it throws the error. Let's first explore some necessary details about the bootstrap/cache directory and then delve into troubleshooting steps that can resolve this issue. 1. Understanding the bootstrap/cache Directory: The bootstrap/cache directory is created by Laravel automatically once you start using it. This folder stores various compiled files, such as a compiled services file, which can be removed during a composer update. It's essential for the smooth functioning of your Laravel app. 2. Why does the error occur? When you run 'composer update,' your project dependencies are updated according to the latest versions. During this process, it removes and recompiles the compiled services file. However, if the bootstrap/cache directory permissions are incorrect or missing entirely, the website fails to load due to insufficient access privileges. The error message is a warning about ensuring the necessary permissions for the cache folder to function correctly. 3. Troubleshooting Steps: To fix this issue, follow these steps: 1. Run 'composer update' again If your project starts functioning as expected after running 'composer update,' you can continue using it without any further troubleshooting. However, keep in mind that the error might resurface later. 2. Check File Permissions: Use the chmod command to set proper permissions for files and folders within your Laravel project. The recommended file permissions are 640 for owners, 480 for groups, and 440 for others. For folders, the suggested permissions are: 2755 for owners, 2750 for groups, and 2710 for others. 3. Chown -R Everything to the Right User/Group: Use the chown command to recursively change ownership of all files in your Laravel project to the right group or user. This ensures that the necessary process can read and write within your cache directory without any issues. 4. Clear Cache and Session Data: Sometimes, clearing the cache and session data might help resolve the issue. Use the 'php artisan route:clear' command in your terminal to clear the routes cache, which may be causing conflicts with other app files. Additionally, you can remove the storage/framework/cache folder and run the 'php artisan cache:clear' command to clear all caches. 5. Update Composer Config File: In some instances, updating a composer config file might solve the issue. To do this, run 'composer config repo.packagist composer https://packagecloud.io/composer/composer-github-mirror' to switch from Packagist mirrors to the GitHub mirror. Afterward, update your composer global config by running 'composer config -g repositories.packagist composer https://packagecloud.io/composer/composer-github-mirror'. 6. Disable Cache and Optimization: Some Laravel configurations may be conflicting with each other. To resolve this conflict, disable the cache and optimization features by adding 'App::disable(Illuminate\Cache\Facades\Cache::class);' to your 'config/app.php' file. This approach might not be ideal in the long run but can help diagnose the problem. 7. Update PHP Version: Sometimes, updating your PHP version might solve this issue, especially if an older version of PHP is causing problems with Laravel's cache-handling methods. Ensure you check for Laravel compatibility before committing to any upgrades. Conclusion: The 'The bootstrap/cache directory must be present and writable' error can occur due to various reasons, such as incorrect file permissions or conflicts within your project. By following the troubleshooting steps outlined above, you should be able to resolve this issue and keep your Laravel app running smoothly. Remember that regular maintenance of a Laravel project plays an essential role in avoiding future problems, and it's always better to consult experts from a reputed company like https://laravelcompany.com/ in case of complex problems.