PHP Fatal error Uncaught Error Class DrushCommands not found in BehatDrushEndpointCommands

(Note: Agaric did not build this site. We inherited it when the client was in desperate straits.)

Why isn’t this happening to anyone else? On an inherited site’s codebase, but i’ve got my coposer.json file looking pretty much the same as Pantheon’s “drops” example.

Fatal error: Uncaught Error: Class 'Drush\Commands\DrushCommands' not found in /var/www/html/drush/Commands/contrib/behat-drush-endpoint/BehatDrushEndpointCommands.php:18
Stack trace:
#0 /var/www/html/web/vendor/drush/drush/includes/annotationcommand_adapter.inc(288): include_once()
#1 /var/www/html/web/vendor/drush/drush/includes/annotationcommand_adapter.inc(269): annotationcommand_adapter_create_commandfile_instance('/var/www/html/d...', '\\Drush\\Commands...')
#2 /var/www/html/web/vendor/drush/drush/includes/annotationcommand_adapter.inc(102): annotationcommand_adapter_get_commands(Array)
#3 /var/www/html/web/vendor/drush/drush/includes/command.inc(1120): annotationcommand_adapter_commands()
#4 /var/www/html/web/vendor/drush/drush/includes/command.inc(1418): drush_get_commands()
#5 /var/www/html/web/vendor/drush/drush/includes/preflight.inc(571): drush_parse_command()
#6 /var/www/html/web/vendor/drush/drush/includes/preflight.inc(64): drush_preflight_command_dispatch()
#7 phar:///usr/local/bin/drush/bin/drush.php(155) in /var/www/html/drush/Commands/contrib/behat-drush-endpoint/BehatDrushEndpointCommands.php on line 18
Drush command terminated abnormally due to an unrecoverable error.                 [error]
Error: Uncaught Error: Class 'Drush\Commands\DrushCommands' not found in
/var/www/html/drush/Commands/contrib/behat-drush-endpoint/BehatDrushEndpointCommands.php:18
Stack trace:
#0
/var/www/html/web/vendor/drush/drush/includes/annotationcommand_adapter.inc(288):
include_once()
#1
/var/www/html/web/vendor/drush/drush/includes/annotationcommand_adapter.inc(269):
annotationcommand_adapter_create_commandfile_instance('/var/www/html/d...',
'\\Drush\\Commands...')
#2
/var/www/html/web/vendor/drush/drush/includes/annotationcommand_adapter.inc(102):
annotationcommand_adapter_get_commands(Array)
#3 /var/www/html/web/vendor/drush/drush/includes/command.inc(1120):
annotationcommand_adapter_commands()
#4 /var/www/html/web/vendor/drush/drush/includes/command.inc(1418):
drush_get_commands()
#5 /var/www/html/web/vendor/drush/drush/includes/preflight.inc(571):
drush_parse_command()
#6 /var/www/html/web/vendor/drush/drush/includes/preflight.inc(64):
drush_preflight_command_dispatch()
#7 phar:///usr/local/bin/drush/bin/drush.php(155) in
/var/www/html/drush/Commands/contrib/behat-drush-endpoint/BehatDrushEndpointCommands.php,
line 18

Removing the entire Behat Drush Endpoint project, drush-ops/behat-drush-endpoint, brings us back to the other error i’ve been fighting with on this project:

Fatal error: Uncaught Error: Class 'TYPO3\PharStreamWrapper\Behavior' not found in /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php:485
Stack trace:
#0 /var/www/html/web/core/includes/utility.inc(38): Drupal\Core\DrupalKernel->boot()
#1 /var/www/html/web/vendor/drush/drush/commands/core/cache.drush.inc(302): drupal_rebuild(Object(Composer\Autoload\ClassLoader), Object(Symfony\Component\HttpFoundation\Request))
#2 /var/www/html/web/vendor/drush/drush/includes/command.inc(422): drush_cache_rebuild()
#3 /var/www/html/web/vendor/drush/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#4 /var/www/html/web/vendor/drush/drush/includes/command.inc(199): drush_command()
#5 /var/www/html/web/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#6 /var/www/html/web/vendor/drush/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#7 /var/www/html/web/vendor/drush/drush/drush.php(12): drush_main()
#8 {main}
  thrown in /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php on line 485
Drush command terminated abnormally due to an unrecoverable error.

OK now trying to run updates, first time it broke on:

[error] Update aborted by: profile_update_8002 [error] Finished performing updates.

and the profile_update_8002 function is super simple

function profile_update_8002() {
  /** @var \Drupal\user\Entity\Role[] $roles */
  $roles = Role::loadMultiple();

  foreach ($roles as $role) {
    if ($role->hasPermission('view profile')) {
      $role->revokePermission('view profile');
      $role->grantPermission('view own profile');
      $role->save();
    }
  }

  return t('Permission name updated.');
}

And in the logs:

2021/01/26 00:52:38 [error] 1732#1732: *1114 FastCGI sent in stderr: “PHP message: Uncaught PHP Exception Symfony\Component\Routing\Exception\RouteNotFoundException: “Route “entity.profile.type.user_profile_form” does not exist.” at /var/www/html/web/core/lib/Drupal/Core/Routing/RouteProvider.php line 208” while reading response header from upstream, client: 172.18.0.6, server: _, request: “GET /dashboard HTTP/1.1”, upstream: “fastcgi://unix:/run/php-fpm.sock:”, host: “ecconnect.ddev.site”

Second time it got passed teh profile update fine and then died on commerce_promotion_post_update_9 with this:

In ProcessBase.php line 188:

Unable to decode output into JSON: Syntax error

Error: Class 'Drupal\commerce_promotion\Plugin\Commerce\PromotionOffer
\FixedAmountOffBase' not found in include() (line 21 of /var/www/html/
web/modules/custom/ec_training/src/Plugin/Commerce/PromotionOffer/DPPTempor
ary.php).

With the stack trace:

[notice] Update started: commerce_promotion_post_update_9 Error: Class ‘Drupal\commerce_promotion\Plugin\Commerce\PromotionOffer\FixedAmountOffBase’ not found in /var/www/html/web/modules/custom/ec_training/src/Plugin/Commerce/PromotionOffer/DPPTemporary.php on line 21 #0 /var/www/html/vendor/composer/ClassLoader.php(444): include() #1 /var/www/html/vendor/composer/ClassLoader.php(322): Composer\Autoload\includeFile(’/var/www/html/w…’) #2 [internal function]: Composer\Autoload\ClassLoader->loadClass(‘Drupal\ec_train…’) #3 [internal function]: spl_autoload_call(‘Drupal\ec_train…’) #4 /var/www/html/web/core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php(96): class_exists(‘Drupal\ec_train…’) #5 /var/www/html/web/core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php(17): Drupal\Component\Plugin\Factory\DefaultFactory::getPluginClass(‘dpp_discount’, Array, ‘Drupal\commerce…’) #6 /var/www/html/web/core/lib/Drupal/Component/Plugin/PluginManagerBase.php(83): Drupal\Core\Plugin\Factory\ContainerFactory->createInstance(‘dpp_discount’, Array) #7 /var/www/html/web/modules/contrib/commerce/src/Plugin/Field/FieldType/PluginItem.php(84): Drupal\Component\Plugin\PluginManagerBase->createInstance(‘dpp_discount’, Array) #8 /var/www/html/web/modules/contrib/commerce/modules/promotion/src/Entity/Promotion.php(232): Drupal\commerce\Plugin\Field\FieldType\PluginItem->getTargetInstance() #9 /var/www/html/web/modules/contrib/commerce/modules/promotion/commerce_promotion.post_update.php(286): Drupal\commerce_promotion\Entity\Promotion->getOffer() #10 /var/www/html/vendor/drush/drush/src/Commands/core/UpdateDBCommands.php(308): commerce_promotion_post_update_9(Array) #11 /var/www/html/vendor/drush/drush/includes/batch.inc(251): Drush\Commands\core\UpdateDBCommands::updateDoOnePostUpdate(‘commerce_promot…’, Object(DrushBatchContext)) #12 /var/www/html/vendor/drush/drush/includes/batch.inc(196): _drush_batch_worker() #13 /var/www/html/vendor/drush/drush/includes/batch.inc(99): _drush_batch_command(‘12439’) #14 /var/www/html/vendor/drush/drush/src/Commands/core/UpdateDBCommands.php(166): drush_batch_command(‘12439’) #15 [internal function]: Drush\Commands\core\UpdateDBCommands->process(‘12439’, Array) #16 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array(Array, Array) #17 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData)) #18 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData)) #19 /var/www/html/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(302): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData)) #20 /var/www/html/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #21 /var/www/html/vendor/symfony/console/Application.php(1005): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #22 /var/www/html/vendor/symfony/console/Application.php(255): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #23 /var/www/html/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #24 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #25 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(49): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput)) #26 /var/www/html/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array) #27 /var/www/html/vendor/drush/drush/drush(4): require(’/var/www/html/v…’) #28 {main} [warning] Drush command terminated abnormally.

But the error clearly blames a custom module on this awful site we inherited.