Kint breaks drush updb for Drupal CMS

Created on 3 February 2025, 20 days ago

Problem/Motivation

I installed Kint for Drupal CMS development, but stucked when try to call drush updb.

Steps to reproduce

$ drush -vvv updb
 [preflight] Config paths: /var/www/html/vendor/drush/drush/drush.yml
 [preflight] Alias paths: /var/www/html/web/drush/sites,/var/www/html/drush/sites
 [preflight] Commandfile search paths: /var/www/html/vendor/drush/drush/src
 [info] Starting bootstrap to full [1.13 sec, 2.74 MB]
 [info] Drush bootstrap phase 5 [1.13 sec, 2.74 MB]
 [info] Try to validate bootstrap phase 5 [1.13 sec, 2.74 MB]
 [info] Try to validate bootstrap phase 5 [1.13 sec, 2.74 MB]
 [info] Try to bootstrap at phase 5 [1.13 sec, 2.74 MB]
 [info] Drush bootstrap phase: bootstrapDrupalRoot() [1.13 sec, 2.74 MB]
 [info] Change working directory to /var/www/html/web [1.13 sec, 2.74 MB]
 [info] Initialized Drupal 11.1.1 root directory at /var/www/html/web [1.13 sec, 2.74 MB]
 [info] Try to validate bootstrap phase 5 [1.13 sec, 2.74 MB]
 [info] Try to bootstrap at phase 5 [1.14 sec, 2.81 MB]
 [info] Drush bootstrap phase: bootstrapDrupalSite() [1.14 sec, 2.81 MB]
 [debug] Could not find a Drush config file at sites/default/drush.yml. [1.14 sec, 2.88 MB]
 [info] Initialized Drupal site drupal-cms.ddev.site at sites/default [1.14 sec, 2.88 MB]
 [info] Try to validate bootstrap phase 5 [1.14 sec, 2.88 MB]
 [info] Try to bootstrap at phase 5 [1.14 sec, 2.88 MB]
 [info] Drush bootstrap phase: bootstrapDrupalConfiguration() [1.14 sec, 2.88 MB]
 [info] Try to validate bootstrap phase 5 [1.15 sec, 2.98 MB]
 [info] Try to bootstrap at phase 5 [1.16 sec, 3.09 MB]
 [info] Drush bootstrap phase: bootstrapDrupalDatabase() [1.16 sec, 3.09 MB]
 [info] Successfully connected to the Drupal database. [1.16 sec, 3.09 MB]
 [info] Try to validate bootstrap phase 5 [1.16 sec, 3.09 MB]
 [info] Try to bootstrap at phase 5 [1.16 sec, 3.09 MB]
 [info] Drush bootstrap phase: bootstrapDrupalFull() [1.16 sec, 3.09 MB]
 [debug] Start bootstrap of the Drupal Kernel. [1.16 sec, 3.09 MB]

In Drupal.php line 169:
                                                                                                             
  [Drupal\Core\DependencyInjection\ContainerNotInitializedException]                                         
  \Drupal::$container is not initialized yet. \Drupal::setContainer() must be called with a real container.  
                                                                                                             

Exception trace:
  at /var/www/html/web/core/lib/Drupal.php:169
 Drupal::getContainer() at /var/www/html/web/core/lib/Drupal.php:414
 Drupal::config() at /var/www/html/web/modules/contrib/kint-kint/kint.module:56
 include_once() at /var/www/html/web/core/lib/Drupal/Core/Hook/HookCollectorPass.php:184
 Drupal\Core\Hook\HookCollectorPass->collectModuleHookImplementations() at /var/www/html/web/core/lib/Drupal/Core/Hook/HookCollectorPass.php:147
 Drupal\Core\Hook\HookCollectorPass::collectAllHookImplementations() at /var/www/html/web/core/lib/Drupal/Core/Hook/HookCollectorPass.php:78
 Drupal\Core\Hook\HookCollectorPass->process() at /var/www/html/vendor/symfony/dependency-injection/Compiler/Compiler.php:73
 Symfony\Component\DependencyInjection\Compiler\Compiler->compile() at /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php:814
 Symfony\Component\DependencyInjection\ContainerBuilder->compile() at /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php:1380
 Drupal\Core\DrupalKernel->compileContainer() at /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php:899
 Drupal\Core\DrupalKernel->initializeContainer() at /var/www/html/web/core/lib/Drupal/Core/Update/UpdateKernel.php:42
 Drupal\Core\Update\UpdateKernel->initializeContainer() at /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php:505
 Drupal\Core\DrupalKernel->boot() at /var/www/html/vendor/drush/drush/src/Boot/DrupalBoot8.php:209
 Drush\Boot\DrupalBoot8->bootstrapDrupalFull() at /var/www/html/vendor/drush/drush/src/Boot/BootstrapManager.php:211
 Drush\Boot\BootstrapManager->doBootstrap() at /var/www/html/vendor/drush/drush/src/Boot/BootstrapManager.php:352
 Drush\Boot\BootstrapManager->bootstrapToPhaseIndex() at /var/www/html/vendor/drush/drush/src/Boot/BootstrapManager.php:304
 Drush\Boot\BootstrapManager->bootstrapToPhase() at /var/www/html/vendor/drush/drush/src/Boot/BootstrapHook.php:36
 Drush\Boot\BootstrapHook->initialize() at /var/www/html/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:44
 Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->doInitializeHook() at /var/www/html/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:36
 Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->callInitializeHook() at /var/www/html/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:29
 Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->initialize() at /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php:145
 Consolidation\AnnotatedCommand\CommandProcessor->initializeHook() at /var/www/html/vendor/consolidation/annotated-command/src/AnnotatedCommand.php:376
 Consolidation\AnnotatedCommand\AnnotatedCommand->initialize() at /var/www/html/vendor/symfony/console/Command/Command.php:245
 Symfony\Component\Console\Command\Command->run() at /var/www/html/vendor/symfony/console/Application.php:1094
 Symfony\Component\Console\Application->doRunCommand() at /var/www/html/vendor/symfony/console/Application.php:342
 Symfony\Component\Console\Application->doRun() at /var/www/html/vendor/symfony/console/Application.php:193
 Symfony\Component\Console\Application->run() at /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php:110
 Drush\Runtime\Runtime->doRun() at /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php:40
 Drush\Runtime\Runtime->run() at /var/www/html/vendor/drush/drush/drush.php:140
 include() at /var/www/html/vendor/bin/drush.php:119

Failed to run drush -vvv updb: exit status 1

Proposed resolution

Fix this code in kint.module:

  $config = \Drupal::config('kint.settings');
  Kint::$enabled_mode = $config->get('early_enable');
  RichRenderer::$theme = $config->get('rich_theme');
  RichRenderer::$timestamp = $config->get('date_format');
  TextRenderer::$timestamp = $config->get('date_format');

// We've disabled helpers in composer in order to make them configurable later.
// For now, load the default ones manually.
  require_once KINT_DIR . '/init_helpers.php';
🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇷🇺Russia Andrew Answer Novosibirsk

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Andrew Answer
  • 🇬🇧United Kingdom catch

    This looks like a general compatibility issue with 11.1. Calling services directly in .module like this is just not supported. The logic could move to a very early event subscriber, or it needs to be changed to use $settings or a container parameter.

Production build 0.71.5 2024