Critical error when disabling WP_DEBUG in Roots Sage 10

I’m getting the following error when I disable WP_DEBUG in Roots Sage 10.

Fatal error: Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /mySite/wp-content/themes/mySite/vendor/illuminate/container/Container.php:1089 Stack trace: #0 /mySite/wp-content/themes/mySite/vendor/illuminate/container/Container.php(886): Illuminate\Container\Container->notInstantiable('Illuminate\\Cont...') #1 /mySite/wp-content/themes/mySite/vendor/illuminate/container/Container.php(758): Illuminate\Container\Container->build('Illuminate\\Cont...') #2 /mySite/wp-content/themes/mySite/vendor/roots/acorn/src/Illuminate/Foundation/Application.php(851): Illuminate\Container\Container->resolve('Illuminate\\Cont...', Array, true) #3 /mySite/wp-content/themes/mySite/vendor/illuminate/container/Container.php(694): Illuminate\Foundation\Application->resolve('Illuminate\\Cont...', Array) in /mySite/wp-content/themes/mySite/vendor/illuminate/container/Container.php on line 1089

A new composer install or composer dump-autoload does not do anything. I’m not sure where to look to solve this.

How exactly did you disable WP_DEBUG?

What version of Sage 10?

What version of Acorn?

I set WP_DEBUG to false in a default WordPress environment (not Bedrock) in wp-config.php.

package.json

{
  "name": "sage",
  "private": true,
  "browserslist": [
    "extends @wordpress/browserslist-config"
  ],
  "engines": {
    "node": ">=16.0.0"
  },
  "scripts": {
    "dev": "bud dev",
    "build": "bud build",
    "translate": "npm run translate:pot && npm run translate:js",
    "translate:pot": "wp i18n make-pot . ./resources/lang/sage.pot --ignore-domain --include=\"app,resources\"",
    "translate:js": "wp i18n make-json ./resources/lang --pretty-print"
  },
  "devDependencies": {
    "@roots/bud": "5.7.6",
    "@roots/bud-tailwindcss": "5.7.6",
    "@roots/sage": "5.7.6"
  },
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^6.1.1",
    "@fortawesome/free-brands-svg-icons": "^6.1.1",
    "@fortawesome/free-regular-svg-icons": "^6.1.1",
    "@fortawesome/free-solid-svg-icons": "^6.1.1"
  }
}

For some reason I can’t find the Sage version number.

Acorn:

            "name": "roots/acorn",
            "version": "v2.0.5",

It’s a multisite.

I installed the Composer dependencies with PHP 8 while the site was running on 7.4. Installing them with 7.4 fixed these issues.

3 Likes

Thank you for following up!

I too am having the same issue on a few new sites.

Development environments are fine but not staging or production.

Setting WP_DEBUG and WP_DEBUG_DISPLAY to true allows me to get around the issue as a temporary workaround.

Using PHP 7.4 to install the packages.

1 Like

Ignore… same problem and solution as @Bart :laughing:

1 Like

I had this pop up suddenly on one theme and not another, both running acorn 2.1.2. It usually stems from an issue in the theme, however sometimes it doesn’t - and it’s difficult to find out what that issue might be. It didn’t for me this time because I reverted commits very far back, to a state I knew was working, rebuilt, and it still gave the illuminate error. I ended up downgrading acorn to 2.0.6 and the issue is gone. If anything, the issue I had was that I was running two sage themes under multisite, and the one producing the error didn’t like that I didn’t also install a composer require to it while the other theme had it. Weird, i know. but that was it.

I ran into the same issue…
How exactly are you doing this? With the platform config option:

  "config": {
    "platform": {
      "php": "7.4"
    }
}

Or are you actually switching php versions locally?
For me the platform option is not working (anymore)…

Thanks!

I believe I used a different version of PHP on the command line.

I can’t seem to get around this issue, I keep on getting this error on the user activation page on my remote servers only:

There has been a critical error on this website.

My php error.log has these lines:

2022/10/27 13:08:44 [error] 825#825: *31 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /srv/www/mydomain.com/releases/20221027124603/web/app/themes/sage-woocommerce/vendor/illuminate/container/Container.php:1089
Stack trace:
#0 /srv/www/mydomain.com/releases/20221027124603/web/app/themes/sage-woocommerce/vendor/illuminate/container/Container.php(886): Illuminate\Container\Container->notInstantiable('Illuminate\\Cont...')
#1 /srv/www/mydomain.com/releases/20221027124603/web/app/themes/sage-woocommerce/vendor/illuminate/container/Container.php(758): Illuminate\Container\Container->build('Illuminate\\Cont...')
#2 /srv/www/mydomain.com/releases/20221027124603/web/app/themes/sage-woocommerce/vendor/roots/acorn/src/Illuminate/Foundation/Application.php(851): Illuminate\Container\Container->resolve('Illuminate\\Cont...', Array, true)
#3 /srv/www/mydomain.com/releases/20221027124603/web/app/themes/sage-woocommerce/vendor/illuminate/conta" while reading response header from upstream, client: 144.178.247.58, server: mydomain.test, request: "GET /wp/wp-activate.php HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm-wordpress.sock:", host: "mydomain.test"

My full debug.log contains:

[27-Oct-2022 11:14:22 UTC] PHP Fatal error:  Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /srv/www/mydomain.com/releases/20221027124603/web/app/themes/sage-woocommerce/vendor/illuminate/container/Container.php:1089
Stack trace:
#0 /srv/www/mydomain.com/releases/20221027124603/web/app/themes/sage-woocommerce/vendor/illuminate/container/Container.php(886): Illuminate\Container\Container->notInstantiable('Illuminate\\Cont...')
#1 /srv/www/mydomain.com/releases/20221027124603/web/app/themes/sage-woocommerce/vendor/illuminate/container/Container.php(758): Illuminate\Container\Container->build('Illuminate\\Cont...')
#2 /srv/www/mydomain.com/releases/20221027124603/web/app/themes/sage-woocommerce/vendor/roots/acorn/src/Illuminate/Foundation/Application.php(851): Illuminate\Container\Container->resolve('Illuminate\\Cont...', Array, true)
#3 /srv/www/mydomain.com/releases/20221027124603/web/app/themes/sage-woocommerce/vendor/illuminate/container/Container.php(694): Illuminate\Foundation\Application->resolve('Illuminate\\Cont...', Array)
#4 /srv/www/mydomain.com/releases/20221027124603/web/app/themes/sage-woocommerce/vendor/roots/acorn/src/Illuminate/Foundation/Application.php(836): Illuminate\Container\Container->make('Illuminate\\Cont...', Array)
#5 /srv/www/mydomain.com/releases/20221027124603/web/app/themes/sage-woocommerce/vendor/roots/acorn/src/Illuminate/Foundation/helpers.php(119): Illuminate\Foundation\Application->make('Illuminate\\Cont...', Array)
#6 /srv/www/mydomain.com/releases/20221027124603/web/app/themes/sage-woocommerce/vendor/roots/acorn/src/Illuminate/Foundation/helpers.php(629): app('Illuminate\\Cont...')
#7 /srv/www/mydomain.com/releases/20221027124603/web/app/themes/sage-woocommerce/vendor/roots/acorn/src/Roots/Acorn/Application.php(397): report(Object(Roots\Acorn\Exceptions\SkipProviderException))
#8 /srv/www/mydomain.com/releases/20221027124603/web/app/themes/sage-woocommerce/vendor/roots/acorn/src/Roots/Acorn/Application.php(330): Roots\Acorn\Application->skipProvider(Object(Log1x\AcfComposer\Providers\AcfComposerServiceProvider), Object(Roots\Acorn\Exceptions\SkipProviderException))
#9 /srv/www/mydomain.com/releases/20221027124603/web/app/themes/sage-woocommerce/vendor/roots/acorn/src/Illuminate/Foundation/Application.php(905): Roots\Acorn\Application->bootProvider(Object(Log1x\AcfComposer\Providers\AcfComposerServiceProvider))
#10 [internal function]: Illuminate\Foundation\Application->Illuminate\Foundation\{closure}(Object(Log1x\AcfComposer\Providers\AcfComposerServiceProvider), 10)
#11 /srv/www/mydomain.com/releases/20221027124603/web/app/themes/sage-woocommerce/vendor/roots/acorn/src/Illuminate/Foundation/Application.php(906): array_walk(Array, Object(Closure))
#12 /srv/www/mydomain.com/releases/20221027124603/web/app/themes/sage-woocommerce/vendor/roots/acorn/src/Illuminate/Foundation/Bootstrap/BootProviders.php(17): Illuminate\Foundation\Application->boot()
#13 /srv/www/mydomain.com/releases/20221027124603/web/app/themes/sage-woocommerce/vendor/roots/acorn/src/Illuminate/Foundation/Application.php(237): Illuminate\Foundation\Bootstrap\BootProviders->bootstrap(Object(Roots\Acorn\Application))
#14 /srv/www/mydomain.com/releases/20221027124603/web/app/themes/sage-woocommerce/vendor/roots/acorn/src/Roots/Acorn/Bootloader.php(208): Illuminate\Foundation\Application->bootstrapWith(Array)
#15 /srv/www/mydomain.com/releases/20221027124603/web/app/themes/sage-woocommerce/vendor/roots/acorn/src/Roots/Acorn/Bootloader.php(181): Roots\Acorn\Bootloader->app()
#16 /srv/www/mydomain.com/releases/20221027131155/web/wp/wp-includes/class-wp-hook.php(307): Roots\Acorn\Bootloader->__invoke('')
#17 /srv/www/mydomain.com/releases/20221027131155/web/wp/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array)
#18 /srv/www/mydomain.com/releases/20221027131155/web/wp/wp-includes/plugin.php(476): WP_Hook->do_action(Array)
#19 /srv/www/mydomain.com/releases/20221027131155/web/wp/wp-settings.php(576): do_action('after_setup_the...')
#20 /srv/www/mydomain.com/releases/20221027131155/web/wp-config.php(9): require_once('/srv/www/urbana...')
#21 /srv/www/mydomain.com/releases/20221027131155/web/wp/wp-load.php(55): require_once('/srv/www/urbana...')
#22 /srv/www/mydomain.com/releases/20221027131155/web/wp/wp-activate.php(12): require('/srv/www/urbana...')
#23 {main}
  thrown in /srv/www/mydomain.com/releases/20221027124603/web/app/themes/sage-woocommerce/vendor/illuminate/container/Container.php on line 1089

In this particular project I’m using the generoi/sage-woocommerce package which installs Acorn (v2.1.2) in my theme folder.

What I tried so far;

  • Switch my local PHP version to 7.4
  • Downgrading Acorn to v2.0.0-beta.8 like suggested in this issue
  • Upgrading my php version in Trellis to 8.0 and switching my local PHP version back to 8.0.
  • Re-publishing the Acorn vendor files with wp @development acorn vendor:publish
  • Completely re-install my composer dependencies in site & theme folder with rm -rf vendor && rm composer.lock && composer install
  • Do a complete re-provision for my remote servers
  • Remove the platform php option in composer.json
  • Move the post-autoload-dump script to the theme folder

Nothing helps, the error stays the same.

The ONLY thing that works is adding this to my site/config/environments/staging.php file:

Config::define('WP_DEBUG', true);
Config::define('WP_DEBUG_DISPLAY', true);

But I obviously don’t want to do this on production?
Any thoughts in what’s going on?

Thanks!

Did you make sure Composer is also actually using PHP7.4?

composer -vvv about 2>&1 | grep "PHP"

Yeah I did that by setting the php option:

  "config": {
    "platform": {
      "php": "7.4"
    }
  }

When I run composer diagnose I can see it’s overriding the PHP version being used.
But even with PHP 8.0 I’m having the same issue?

I don’t have a solution but hopefully this adds to the discussion and someone with more Laravel skills can pick it up. It may also be that the problem is irrelevant since there always seem to be an underlying problem that needs to be fixed regardless.

I run into basically the same error:

Fatal error: Uncaught Exception: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable.
in /home/vagrant/code/web/app/themes/theme-name/vendor/illuminate/container/Container.php on line 1089

when WP_DEBUG and WP_DEBUG_DISPLAY is set to true. The culprit in my case is Corcel and more specifically this line. Having said that, the originating error is probably irrelevant and the final error that we all have in common will arise as soon as something goes wrong when booting the app. Of course, the originating errors should be fixed as well but let’s deal with the error we all have in common here.

Comparing the debug.log in Twansparants post with mine, the common culprit seems to be the function report() which, in our stacks, are called by skipProvider() where ExceptionHandler::class seems to be Illuminate\Contracts\Debug\ExceptionHandler which is an interface which, I assume, is what is somehow causing the “is not instantiable” error.

This is about as far as I can go before loosing grip on what the code actually does (even though I am reading up on Laravel). Googling “illuminate Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable” renders some results but I can not see that any of them has a solution that is applicablie to my (our?) cases.

I am running

  • Sage 10
  • Acorn 2.1.2 (tried downgrading but no luck)
  • PHP 8.0 (both on the server and when runnnng composer)

I have deleted vendor folders, run composer dump-autoload, deleted the cache-folder and all other things I can come up with to no avail.

Bonus: By doing dd($e); on line 330 and 398 in vendor/roots/acorn/src/Roots/Acorn/Application.php we can get more details on the originating error. In my case it is “Skipping provider [Corcel\Laravel\CorcelServiceProvider] because it requires a dependency that cannot be found.” and “Target class [auth] does not exist.”.

My error call stack for reference:

Illuminate\Container\Container::notInstantiable()
app/themes/theme-name/vendor/illuminate/container/Container.php:886
Illuminate\Container\Container::build()
app/themes/theme-name/vendor/illuminate/container/Container.php:758
Illuminate\Container\Container::resolve()
/home/vagrant/code/vendor/roots/acorn/src/Illuminate/Foundation/Application.php:851
Illuminate\Foundation\Application::resolve()
app/themes/theme-name/vendor/illuminate/container/Container.php:694
Illuminate\Container\Container::make()
/home/vagrant/code/vendor/roots/acorn/src/Illuminate/Foundation/Application.php:836
Illuminate\Foundation\Application::make()
/home/vagrant/code/vendor/roots/acorn/src/Illuminate/Foundation/helpers.php:119
app()
/home/vagrant/code/vendor/roots/acorn/src/Illuminate/Foundation/helpers.php:629
report()
/home/vagrant/code/vendor/roots/acorn/src/Roots/Acorn/Application.php:397
Roots\Acorn\Application::skipProvider()
/home/vagrant/code/vendor/roots/acorn/src/Roots/Acorn/Application.php:330
Roots\Acorn\Application::bootProvider()
/home/vagrant/code/vendor/roots/acorn/src/Illuminate/Foundation/Application.php:905
Illuminate\F\Application::Illuminate\F\{closure}()
array_walk()
/home/vagrant/code/vendor/roots/acorn/src/Illuminate/Foundation/Application.php:906
Illuminate\Foundation\Application::boot()
/home/vagrant/code/vendor/roots/acorn/src/Illuminate/Foundation/Bootstrap/BootProviders.php:17
Illuminate\F\B\BootProviders::bootstrap()
/home/vagrant/code/vendor/roots/acorn/src/Illuminate/Foundation/Application.php:237
Illuminate\Foundation\Application::bootstrapWith()
/home/vagrant/code/vendor/roots/acorn/src/Roots/Acorn/Bootloader.php:208
Roots\Acorn\Bootloader::app()
/home/vagrant/code/vendor/roots/acorn/src/Roots/Acorn/Bootloader.php:181
Roots\Acorn\Bootloader::__invoke()
wp-includes/class-wp-hook.php:307
WP_Hook::apply_filters()
wp-includes/class-wp-hook.php:331
WP_Hook::do_action()
wp-includes/plugin.php:476
do_action()
wp-settings.php:576
require_once()
wp-config.php:9
require_once()
wp-load.php:55
require_once()
wp-admin/admin.php:34
require_once()
4 Likes

Yes, thanks for this :pray:

This helped me a lot fixing the original problem! I wouldn’t have found this otherwise.
At least my critical error is gone now, but it would be great if you can actually see these errors somewhere in a log file.

I also don’t know enough about Laravel or Acorn to come up with a solution…

1 Like

I was having this issue also and believe that it is related to barryvdh/laravel-debugbar and/or query-monitor plugin.

removing those prevents the error while in production mode, but also it appears that the Acorn exception handler will handle skipProvider exceptions silently, maybe through the logger when in development mode. But while in production, the Query monitor exception handler kicks in, and or wordpress’s own fatal exception handler which will result in the unexpected error page.

Hmm I’m not using any of those plugins on this site?
I still don’t know what the cause is of this, but it’s definitely related to Acorn.

Nothing useful to add, other than I’m having the same issue on remote servers.

Like others, I can get everything to “work” by setting debug/display true.

I too am on PHP 8.1, acorn 2.1.2
I have tried Acorn through composer, and as a plugin - the same result/

It is fine(ish) for staging right now, but leaves deploys to production broken. :anguished:

Maybe @QWp6t or @Log1x could have a look at this.

So I dug a little deeper and came up with a way to diagnose my problem that isn’t involving PHP versions etc. Once I made the following changes, it was pretty easy to see where the real issue was:

Step one - restore the logging to file
as @Log1x mentions here: Bug: Broken packages/providers are silently skipped · Issue #250 · roots/acorn · GitHub
Adding the logging.php file back in, as @dave referenced here: Log files not being created? - #2 by alwaysblank

Helped me see additional logging in web>app>cache>acorn>logs>application.php

Once I saw this file, it helped me find the real cause of the issue that was throwing my Roots\Acorn\View\ViewServiceProvider into an error

(my cause was an incorrect class reference that gets built dynamically somewhere else in my code)

Hope this helps!