Search code examples
laravellaravel-artisan

Got error ExceptionWrapper in Finder.php line 590 the directory "" does not exist when run artisan test


This problem occurs after I upgrade my Laravel from 8 to 9. At first running single test function in a feature test was not a problem. But then after I added a 2nd test function, when ever I tried to run "artisan test", I got the following error

PHPUnit\Framework\ExceptionWrapper 

  The "" directory does not exist.

  at vendor/symfony/finder/Finder.php:590

This error did not happen when I run any other artisan command. Only when running "artisan test" and when I have multiple functions within a single feature test.

So what I have done so far:

  • At first I thought I was missing a directory, but that was not the case.
  • Than I tried to run "composer dump-autoload", the error is still persistence.
  • Next tried to removing vendor directory and run "composer install", again error is still there.
  • I also tried some solutions for other "stack overflow question", like checking .gitignore list, debug from the code. Not helping, probably due to different exception case?
  • Someone mention run "composer update", I have tried it but this is not solution for my problem.
  • For laravel.log (as pointed out by @UnderDog, thanks for your comment) here is the error stack.

local.ERROR: The "" directory does not exist. {"exception":"[object] (Symfony\\Component\\Finder\\Exception\\DirectoryNotFoundException(code: 0): The \"\" directory does not exist. at .../vendor/symfony/finder/Finder.php:592) [stacktrace] .../vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php(86): Symfony\\Component\\Finder\\Finder->in('') .../vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php(63): Illuminate\\Foundation\\Bootstrap\\LoadConfiguration->getConfigurationFiles(Object(Illuminate\\Foundation\\Application)) .../vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php(39): Illuminate\\Foundation\\Bootstrap\\LoadConfiguration->loadConfigurationFiles(Object(Illuminate\\Foundation\\Application), Object(Illuminate\\Config\\Repository)) .../vendor/laravel/framework/src/Illuminate/Foundation/Application.php(242): Illuminate\\Foundation\\Bootstrap\\LoadConfiguration->bootstrap(Object(Illuminate\\Foundation\\Application)) .../vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(383): Illuminate\\Foundation\\Application->bootstrapWith(Array)
...

This was exception trigger when running "artisan optimize" as well as "artisan test" (with multiple tests in a single file.


Solution

  • Turns out this error originated from my poor choice of variable name inside .env .

    I used a variable name APP_BASE_PATH="public_html" inside my .env file. And boy that was a mistake that not only make artisan test, but also artisan optimize to be totally "disabled".

    So after I change it to PUBLIC_DIR="public_shtml" my artisan command works again.

    I learn my lesson not to use any variable name inside .env without checking it first if it's used by core or any libraries that I used.

    So I guess APP_BASE_PATH is a reserved name in Laravel core ?