"target class [composer] does not exist"

Since updating to Acorn 3.2.0, I’ve been seeing the following error when attempting to run wp acorn in my DDEV container:

$ ddev wp acorn

In Container.php line 891:

  Target class [composer] does not exist.


In Container.php line 889:

  Class "composer" does not exist


Failed to run wp acorn: exit status 1

I’ve tried clearing cache to no avail. I’ve also re-created the containers with ddev restart. And, unfortunately, I only see third-party dependencies in the stack trace, so I’m not sure whether this is related to my code. I’m willing to provide some sample code if that’d be helpful, but it’s not clear to me what might be helpful context there.

Here’s the full trace as it appears in application.log:

[2023-06-26 15:21:00] development.ERROR: Target class [composer] does not exist. {"exception":"[object] (Illuminate\\Contracts\\Container\\BindingResolutionExc
eption(code: 0): Target class [composer] does not exist. at /var/www/html/web/app/themes/logan-center/vendor/illuminate/container/Container.php:891)
[stacktrace]
#0 /var/www/html/web/app/themes/logan-center/vendor/illuminate/container/Container.php(770): Illuminate\\Container\\Container->build('composer')
#1 /var/www/html/vendor/roots/acorn/src/Illuminate/Foundation/Application.php(856): Illuminate\\Container\\Container->resolve('composer', Array, true)
#2 /var/www/html/web/app/themes/logan-center/vendor/illuminate/container/Container.php(706): Illuminate\\Foundation\\Application->resolve('composer', Array)
#3 /var/www/html/vendor/roots/acorn/src/Illuminate/Foundation/Application.php(841): Illuminate\\Container\\Container->make('composer', Array)
#4 /var/www/html/web/app/themes/logan-center/vendor/illuminate/container/Container.php(1431): Illuminate\\Foundation\\Application->make('composer')
#5 /var/www/html/vendor/illuminate/database/MigrationServiceProvider.php(159): Illuminate\\Container\\Container->offsetGet('composer')
#6 /var/www/html/web/app/themes/logan-center/vendor/illuminate/container/Container.php(885): Illuminate\\Database\\MigrationServiceProvider->Illuminate\\Databa
se\\{closure}(Object(Roots\\Acorn\\Application), Array)
#7 /var/www/html/web/app/themes/logan-center/vendor/illuminate/container/Container.php(770): Illuminate\\Container\\Container->build(Object(Closure))
#8 /var/www/html/vendor/roots/acorn/src/Illuminate/Foundation/Application.php(856): Illuminate\\Container\\Container->resolve('Illuminate\\\\Data...', Array, t
rue)
#9 /var/www/html/web/app/themes/logan-center/vendor/illuminate/container/Container.php(706): Illuminate\\Foundation\\Application->resolve('Illuminate\\\\Data..
.', Array)
#10 /var/www/html/vendor/roots/acorn/src/Illuminate/Foundation/Application.php(841): Illuminate\\Container\\Container->make('Illuminate\\\\Data...', Array)
#11 /var/www/html/vendor/illuminate/console/Application.php(280): Illuminate\\Foundation\\Application->make('Illuminate\\\\Data...')
#12 /var/www/html/vendor/illuminate/console/Application.php(294): Illuminate\\Console\\Application->resolve('Illuminate\\\\Data...')
#13 /var/www/html/web/app/themes/logan-center/vendor/illuminate/support/ServiceProvider.php(404): Illuminate\\Console\\Application->resolveCommands(Array)
#14 /var/www/html/vendor/illuminate/console/Application.php(161): Illuminate\\Support\\ServiceProvider->Illuminate\\Support\\{closure}(Object(Illuminate\\Conso
le\\Application))
#15 /var/www/html/vendor/illuminate/console/Application.php(82): Illuminate\\Console\\Application->bootstrap()
#16 /var/www/html/vendor/roots/acorn/src/Illuminate/Foundation/Console/Kernel.php(417): Illuminate\\Console\\Application->__construct(Object(Roots\\Acorn\\Appl
ication), Object(Illuminate\\Events\\Dispatcher), 'Acorn 3.2.0 (La...')
#17 /var/www/html/vendor/roots/acorn/src/Illuminate/Foundation/Console/Kernel.php(155): Illuminate\\Foundation\\Console\\Kernel->getArtisan()
#18 /var/www/html/vendor/roots/acorn/src/Roots/Acorn/Bootloader.php(185): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\I
nput\\StringInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#19 [internal function]: Roots\\Acorn\\Bootloader->Roots\\Acorn\\{closure}(Array, Array)
#20 phar:///usr/local/bin/wp-cli/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(102): call_user_func(Object(Closure), Array, Array)
#21 [internal function]: WP_CLI\\Dispatcher\\CommandFactory::WP_CLI\\Dispatcher\\{closure}(Array, Array)
#22 phar:///usr/local/bin/wp-cli/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(491): call_user_func(Object(Closure), Array, Array)
#23 phar:///usr/local/bin/wp-cli/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(419): WP_CLI\\Dispatcher\\Subcommand->invoke(Array, Array, Array)
#24 phar:///usr/local/bin/wp-cli/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(442): WP_CLI\\Runner->run_command(Array, Array)
#25 phar:///usr/local/bin/wp-cli/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1256): WP_CLI\\Runner->run_command_and_exit()
#26 phar:///usr/local/bin/wp-cli/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\\Runner->start()
#27 phar:///usr/local/bin/wp-cli/vendor/wp-cli/wp-cli/php/bootstrap.php(78): WP_CLI\\Bootstrap\\LaunchRunner->process(Object(WP_CLI\\Bootstrap\\BootstrapState)
)
#28 phar:///usr/local/bin/wp-cli/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\\bootstrap()
#29 phar:///usr/local/bin/wp-cli/php/boot-phar.php(11): include('phar:///usr/loc...')
#30 /usr/local/bin/wp-cli(4): include('phar:///usr/loc...')
#31 {main}

Upgrading to v3.2.0 from what version?

Did you already have any published directories, like config/?

Which cache? What files/folders did you remove?

Upgrading to v3.2.0 from what version?

3.1.0

Did you already have any published directories, like config/?

Yup:

❯ tree config
config
├── acf.php
├── app.php
├── assets.php
├── blade-icons.php
├── blade-lucide-icons.php
├── filesystems.php
├── ignition.php
├── logging.php
├── services.php
├── session.php
├── svg.php
└── view.php

Which cache? What files/folders did you remove?

Sorry, should have specified: in a Bedrock installation, I removed web/app/cache/. Are there any other places where some old state might be living?

Try applying the changes from config/app.php:

2 Likes

Wow, thank you for pointing me back there. That fixed the issue.

I did update app.php but clearly I did that without looking at the actual diff, assuming that it was only the \Illuminate\Database providers that needed adding.

Also, FWIW: I had removed all of the references to non-existent classes from the default config/app.php list [src] (including Illuminate\Database\DatabaseServiceProvider) because PHPStan and PHPStorm both flag them as errors:

 ------ -------------------------------------------------------------------------
  Line   config/app.php
 ------ -------------------------------------------------------------------------
  175    Class Illuminate\Auth\AuthServiceProvider not found.
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
  176    Class Illuminate\Broadcasting\BroadcastServiceProvider not found.
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
  177    Class Illuminate\Cookie\CookieServiceProvider not found.
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
  179    Class Illuminate\Encryption\EncryptionServiceProvider not found.
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
  180    Class Illuminate\Hashing\HashServiceProvider not found.
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
  181    Class Illuminate\Mail\MailServiceProvider not found.
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
  182    Class Illuminate\Notifications\NotificationServiceProvider not found.
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
  183    Class Illuminate\Queue\QueueServiceProvider not found.
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
  184    Class Illuminate\Redis\RedisServiceProvider not found.
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
  185    Class Illuminate\Auth\Passwords\PasswordResetServiceProvider not found.
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
  186    Class Illuminate\Translation\TranslationServiceProvider not found.
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
  187    Class Illuminate\Validation\ValidationServiceProvider not found.
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
 ------ -------------------------------------------------------------------------