Laravel 6 includes some additional configuration in phpunit.xml:
<server name="APP_CONFIG_CACHE" value="bootstrap/cache/config.phpunit.php"/>
<server name="APP_SERVICES_CACHE" value="bootstrap/cache/services.phpunit.php"/>
<server name="APP_PACKAGES_CACHE" value="bootstrap/cache/packages.phpunit.php"/>
<server name="APP_ROUTES_CACHE" value="bootstrap/cache/routes.phpunit.php"/>
<server name="APP_EVENTS_CACHE" value="bootstrap/cache/events.phpunit.php"/>
If I run the tests in PHPStorm, I get the following error:
In PackageManifest.php line 168:
The bootstrap/cache directory must be present and writable.
But the bootstrap/cache directory is indeed present and writable. However, if I comment out those new configs in phpunit.xml, my tests run without any errors. How do I fix this?
I also ran php artisan cache:clear
. No luck.
If you're running Linux, most likely it's a read/write permission problem, to solve these problems, do the following:
Before doing the steps below, be sure to be outside of your Laravel folder
Assuming that your user
should be the owner, type the following command:
sudo chown -R user:www-data /path/of/your/laravel/project
Then give the user and webserver permissions as follows:
sudo find /path/of/your/laravel/project -type f -exec chmod 664 {} \;
then run:
sudo find /path/of/your/laravel/project -type d -exec chmod 775 {} \;
After you run those commands, go to your Laravel folder and give the webserver rights to read/write to your bootstrap/cache
and storage
folder:
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
It should solve not only your problem but also solves your project security.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With