Fatal error: Uncaught Error: Call to undefined method Roots\Acorn\Bootloader::boot()

Hi,

I have upgraded Acorn v2 to v3 on a sage10 -theme following these instructions: Upgrading Acorn | Acorn Docs | Roots.
Everything works as it should on local development, no problem there. However when I am running the same site on a live server I am getting following error on terminal:

#8 {main}
** thrown in /data/wordpress/htdocs/wp-content/themes/mythemename/functions.php on line 43**
Fatal error: Uncaught Error: Call to undefined method Roots\Acorn\Bootloader::boot() in /data/wordpress/htdocs/wp-content/themes/mythemename/functions.php:43

Line 43 in functions.php is:
\Roots\bootloader()->boot();

This causes “critical error” on the website. If i comment out the line 43, I am able to access the wp-admin panel and not getting anymore errors on the server side. However, then I am not able to access the front which gives “There has been critical error”.
The php-error.log then gives undefined function app() in acorn -error:

PHP Fatal error: Uncaught Error: Call to undefined function app() in /data/wordpress/vendor/roots/acorn/src/Roots/helpers.php:37

Any help on pinpointing and solving the problem would be appreciated. Thanks!

Hi @talentreeweb,

Have you verified that Acorn 3.x is actually being loaded, not 2.x?

Hi @talss89 , sorry for a possibly dumb question but how can I verify if Acorn 3.x is loaded? (I am new to sage10 but have been using sage9 for years so Acorn is new to me).

When i ran “composer update” it said updated Acorn from v2 to v3.
But when i run some acorn-command, for example “wp acorn env” I get error “Error: ‘acorn’ is not a registered wp command. See ‘wp help’ for available commands.
Did you mean ‘core’?”

On other live server where I have sage10 theme and the acorn works, the “wp acorn env” -command gives “Current application environment: production”. This would suggest that your theory about Acorn not loading might be true, but I have no idea how to test that.

For more info, I would imagine that the Acorn IS loaded since if i edit roots/acorn/src/Roots/helpers.php and add wp_die function inside the bootloader() -function, the wp_die() works:

image

But when I edit the Bootloader.php getInstance() -function that the helpers.php line 51 refers to, it doesnt work. Added wp_die() there but the function doesnt click:


And getting the same error message on server if i ran for example “wp plugin list” command:

functions.php line 44 being \Roots\bootloader()->boot();

More information about the problem. On three different instances, when using var_dump($bootloader); on helpers.php I get the following (the instance where the Bootloader doestnt work gives different dump than the others), any idea on why this is happening and how can i fix it?

// LIVE site, Bootloader errors
object(Roots\Acorn\Bootloader)#8319 (6) { [“app”:protected]=> NULL [“appClassName”:protected]=> string(23) “Roots\Acorn\Application” [“hooks”:protected]=> array(2) { [0]=> string(17) “after_setup_theme” [1]=> string(13) “rest_api_init” } [“queue”:protected]=> array(0) { } [“ready”:protected]=> bool(false) [“basePath”:protected]=> NULL }

// LOCAL development, Bootloader works
object(Roots\Acorn\Bootloader)#12406 (3) { [“app”:protected]=> NULL [“basePath”:protected]=> NULL [“absoluteApplicationPathPrefixes”:protected]=> array(2) { [0]=> string(1) “/” [1]=> string(1) "" } }

// Other LIVE site, Bootloader works, same response as the local that works
object(Roots\Acorn\Bootloader)#5628 (3) { [“app”:protected]=> NULL [“basePath”:protected]=> NULL [“absoluteApplicationPathPrefixes”:protected]=> array(2) { [0]=> string(1) “/” [1]=> string(1) "" } }

image

Hi @talentreeweb,

Thanks for the info. Let’s ignore the live server that works for the moment to keep things simple.

I’d try:

  • Ensuring composer.json and composer.lock are identical between your dev and live environments
  • Delete vendor/ directory on live environment
  • Run composer install on live environment

That will ensure you’re installing the same dependencies on live as you are on dev. That will put us in a clean state to diagnose further, if required.

1 Like

Hi,

You can also try to delete the vendor located in the theme and run a new install in the theme folder.

How do you deploy to this server? What does deployment look like?

Is the server running PHP 8.0+?

Thanks for the answers, I had tried all of those solutions before and didnt get the site working.

BUT now the site works, the cause for the problem was the type of “human error”. For some reason I forgot to push some of the Acorn3 -related changes to git from my local development site, so the livesite that was not working was at the same state as the local version.

I just pushed the newest changes to git and pulled them from the live server, and everything is okay :smiley:

1 Like