Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drush 13 fails with: AssertionError: Instead of using replacing Drush's logger, use $this->add() on DrushLoggerManager to add a custom logger #6231

Open
apotek opened this issue Feb 14, 2025 · 1 comment

Comments

@apotek
Copy link
Contributor

apotek commented Feb 14, 2025

Describe the bug
I'm here because I am seeing this exception after trying to update to Drush 13.

The stack trace mentions no custom code. Everything emits from within vendor/drush.

In addition, after seeing the exception, I removed all my custom Drush commands from my application, cleared cache via the admin UI, and the error still appears.

The merge request mentioned in the Exception has been in Drush since v 11.0.1. I downgraded to Drush 13.2, 13.1, and 13.0 and all of them have this issue. I cleared cache via admin UI since I can't run cache:rebuild, between each version change.

When I first saw the exception, I looked at my custom Command Alterer which followed the Docs and did this:

  use AutowireTrait;

  /**
   * The drush logger channel.
   */
  protected LoggerChannelInterface $logger;

  public function __construct(LoggerChannelFactoryInterface $loggerFactory) {
    $this->logger = $loggerFactory->get('drush');
  }

But as I mentioned, in troubleshooting the error, I have removed the command alterer and all other custom commands, so that is not the cause of the issue. There are no Drush commands in custom/ and the stack trace is all local to vendor/drush.

Stack Trace

AssertionError: Instead of using replacing Drush's logger, use $this->add() on DrushLoggerManager to add a custom logger. See #5022 in /var/www/html/vendor/drush/drush/src/Commands/DrushCommands.php on line 76 #0 /var/www/html/vendor/drush/drush/src/Commands/DrushCommands.php(76): assert()
#1 /var/www/html/vendor/drush/drush/src/Runtime/ServiceManager.php(480): Drush\Commands\DrushCommands->logger()
#2 /var/www/html/vendor/drush/drush/src/Boot/DrupalBoot8.php(282): Drush\Runtime\ServiceManager->inflect()
#3 /var/www/html/vendor/drush/drush/src/Boot/DrupalBoot8.php(218): Drush\Boot\DrupalBoot8->addDrupalModuleDrushCommands()
#4 /var/www/html/vendor/drush/drush/src/Boot/BootstrapManager.php(211): Drush\Boot\DrupalBoot8->bootstrapDrupalFull()
#5 /var/www/html/vendor/drush/drush/src/Boot/BootstrapManager.php(397): Drush\Boot\BootstrapManager->doBootstrap()
#6 /var/www/html/vendor/drush/drush/src/Application.php(219): Drush\Boot\BootstrapManager->bootstrapMax()
#7 /var/www/html/vendor/drush/drush/src/Application.php(185): Drush\Application->bootstrapAndFind()
#8 /var/www/html/vendor/symfony/console/Application.php(266): Drush\Application->find()
#9 /var/www/html/vendor/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun()
#10 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(110): Symfony\Component\Console\Application->run()
#11 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(40): Drush\Runtime\Runtime->doRun()
#12 /var/www/html/vendor/drush/drush/drush.php(140): Drush\Runtime\Runtime->run()
#13 /var/www/html/vendor/bin/drush.php(119): include('...')
#14 {main}

To Reproduce

ddev composer require drush/drush:^13

Expected behavior
To be able to run basic Drush commands like drush status and drush cache:rebuild without error.

Actual behavior
Exception thrown.

Workaround
No. All Drush commands fail.

System Configuration

Q A
Drush version? 13.3.3.0 (Also with 13.2, 13.1, 13.0) Bug does not appear with Drush 12.
Drupal version? 10.4.x
PHP version 8.3
OS? Mac/Linux/Windows (DDEV/linux)

Additional information
Add any other context about the problem here.

@apotek
Copy link
Contributor Author

apotek commented Feb 14, 2025

Reverting back down to Drush 12.5.3 fixes the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant