Critical error when disabling WP_DEBUG in Roots Sage 10

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!