kerryjones's avatar

A facade root has not been set. - Laravel 5.6 Upgrade

I started Laravel Shift and was near the end, trying to run composer update, and now it throws this error:

> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover
PHP Fatal error:  Uncaught RuntimeException: A facade root has not been set. in /home/vagrant/Code/hubhaus/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:218
Stack trace:
#0 /home/vagrant/Code/hubhaus/app/Exceptions/Handler.php(46): Illuminate\Support\Facades\Facade::__callStatic('environment', Array)
#1 /home/vagrant/Code/hubhaus/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(353): App\Exceptions\Handler->report(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#2 /home/vagrant/Code/hubhaus/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(132): Illuminate\Foundation\Console\Kernel->reportException(Object(Symfony\Component\Debug\Exception\FatalThrowableError))

#3 /home/vagrant/Code/hubhaus/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 {main}
  thrown in /home/vagrant/Code/hubhaus/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 218

Fatal error: Uncaught RuntimeException: A facade root has not been set. in /home/vagrant/Code/hubhaus/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:218
Stack trace:
#0 /home/vagrant/Code/hubhaus/app/Exceptions/Handler.php(46): Illuminate\Support\Facades\Facade::__callStatic('environment', Array)
#1 /home/vagrant/Code/hubhaus/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(353): App\Exceptions\Handler->report(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#2 /home/vagrant/Code/hubhaus/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(132): Illuminate\Foundation\Console\Kernel->reportException(Object(Symfony\Component\Debug\Exception\FatalThrowableError))

#3 /home/vagrant/Code/hubhaus/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 {main}
  thrown in /home/vagrant/Code/hubhaus/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 218
Script @php artisan package:discover handling the post-autoload-dump event returned with error code 255

Does anyone know what's happening? How do I fix this?

0 likes
2 replies
skiat's avatar

Do you use TrustProxy middleware?

I had the same problem... and the error happened also in my exception Handler.php! If I removed the environment check the issue propagates to eloquent and more..

I found that app/bootstrap/cache was empty, then I simply continued reading the https://laravel.com/docs/5.6/upgrade#upgrade-5.6.0 guide and found that change on Trusted Proxies

so my configuration was still using the $headers = [/array of header names/] and once changed to one of the possible HEADER_X... bitmast values the error disappeared!

i hope this may help you too ;)

1 like
martijnimhoff's avatar

Did you find a solution? Updating TrustProxy middleware did not work for me.

Please or to participate in this conversation.