5

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.

Tanmay
  • 2,380
  • 5
  • 34
  • 69

2 Answers2

5

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.

rkg
  • 670
  • 3
  • 14
1

This was an issue from Laravel end:

https://github.com/laravel/framework/issues/29862

This PR Fixes that issue.

Updating the framework version to the latest version (6.0.3 as of the time of this answer) fixes the problem.

Tanmay
  • 2,380
  • 5
  • 34
  • 69