(I'm actually using 4.0.0-alpha4 but I don't see that as an option in the issue fields.)

It seems that Drupal Console is actually required despite just being a dev dependency. Attempting to load the site without it installed showed:

Error: Trait 'Drupal\Console\Command\Shared\ConfirmationTrait' not found in /var/www/docroot/profiles/contrib/lightning/src/Command/SubProfileCommand.php, line 29

Here's the full call stack:

Array
(
    [0] => Array
        (
            [file] => phar:///usr/local/bin/drush/vendor/composer/ClassLoader.php
            [line] => 444
            [function] => include
        )
    [1] => Array
        (
            [file] => phar:///usr/local/bin/drush/vendor/composer/ClassLoader.php
            [line] => 322
            [function] => Composer\Autoload\includeFile
        )
    [2] => Array
        (
            [function] => loadClass
            [class] => Composer\Autoload\ClassLoader
            [type] => ->
        )
    [3] => Array
        (
            [function] => spl_autoload_call
        )
    [4] => Array
        (
            [file] => /var/www/vendor/symfony/dependency-injection/ContainerBuilder.php
            [line] => 371
            [function] => __construct
            [class] => ReflectionClass
            [type] => ->
        )
    [5] => Array
        (
            [file] => /var/www/vendor/symfony/dependency-injection/Compiler/AutowirePass.php
            [line] => 363
            [function] => getReflectionClass
            [class] => Symfony\Component\DependencyInjection\ContainerBuilder
            [type] => ->
        )
    [6] => Array
        (
            [file] => /var/www/vendor/symfony/dependency-injection/Compiler/AutowirePass.php
            [line] => 336
            [function] => populateAvailableType
            [class] => Symfony\Component\DependencyInjection\Compiler\AutowirePass
            [type] => ->
        )
    [7] => Array
        (
            [file] => /var/www/vendor/symfony/dependency-injection/Compiler/AutowirePass.php
            [line] => 292
            [function] => populateAvailableTypes
            [class] => Symfony\Component\DependencyInjection\Compiler\AutowirePass
            [type] => ->
        )
    [8] => Array
        (
            [file] => /var/www/vendor/symfony/dependency-injection/Compiler/AutowirePass.php
            [line] => 248
            [function] => getAutowiredReference
            [class] => Symfony\Component\DependencyInjection\Compiler\AutowirePass
            [type] => ->
        )
    [9] => Array
        (
            [file] => /var/www/vendor/symfony/dependency-injection/Compiler/AutowirePass.php
            [line] => 187
            [function] => autowireMethod
            [class] => Symfony\Component\DependencyInjection\Compiler\AutowirePass
            [type] => ->
        )
    [10] => Array
        (
            [file] => /var/www/vendor/symfony/dependency-injection/Compiler/AutowirePass.php
            [line] => 153
            [function] => autowireCalls
            [class] => Symfony\Component\DependencyInjection\Compiler\AutowirePass
            [type] => ->
        )
    [11] => Array
        (
            [file] => /var/www/vendor/symfony/dependency-injection/Compiler/AutowirePass.php
            [line] => 109
            [function] => doProcessValue
            [class] => Symfony\Component\DependencyInjection\Compiler\AutowirePass
            [type] => ->
        )
    [12] => Array
        (
            [file] => /var/www/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php
            [line] => 60
            [function] => processValue
            [class] => Symfony\Component\DependencyInjection\Compiler\AutowirePass
            [type] => ->
        )
    [13] => Array
        (
            [file] => /var/www/vendor/symfony/dependency-injection/Compiler/AutowirePass.php
            [line] => 130
            [function] => processValue
            [class] => Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass
            [type] => ->
        )
    [14] => Array
        (
            [file] => /var/www/vendor/symfony/dependency-injection/Compiler/AutowirePass.php
            [line] => 109
            [function] => doProcessValue
            [class] => Symfony\Component\DependencyInjection\Compiler\AutowirePass
            [type] => ->
        )
    [15] => Array
        (
            [file] => /var/www/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php
            [line] => 39
            [function] => processValue
            [class] => Symfony\Component\DependencyInjection\Compiler\AutowirePass
            [type] => ->
        )
    [16] => Array
        (
            [file] => /var/www/vendor/symfony/dependency-injection/Compiler/AutowirePass.php
            [line] => 70
            [function] => process
            [class] => Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass
            [type] => ->
        )
    [17] => Array
        (
            [file] => /var/www/vendor/symfony/dependency-injection/Compiler/Compiler.php
            [line] => 141
            [function] => process
            [class] => Symfony\Component\DependencyInjection\Compiler\AutowirePass
            [type] => ->
        )
    [18] => Array
        (
            [file] => /var/www/vendor/symfony/dependency-injection/ContainerBuilder.php
            [line] => 788
            [function] => compile
            [class] => Symfony\Component\DependencyInjection\Compiler\Compiler
            [type] => ->
        )
    [19] => Array
        (
            [file] => /var/www/docroot/core/lib/Drupal/Core/DrupalKernel.php
            [line] => 1318
            [function] => compile
            [class] => Symfony\Component\DependencyInjection\ContainerBuilder
            [type] => ->
        )
    [20] => Array
        (
            [file] => /var/www/docroot/core/lib/Drupal/Core/DrupalKernel.php
            [line] => 892
            [function] => compileContainer
            [class] => Drupal\Core\DrupalKernel
            [type] => ->
        )
    [21] => Array
        (
            [file] => /var/www/docroot/core/lib/Drupal/Core/DrupalKernel.php
            [line] => 468
            [function] => initializeContainer
            [class] => Drupal\Core\DrupalKernel
            [type] => ->
        )
    [22] => Array
        (
            [file] => /var/www/docroot/core/lib/Drupal/Core/DrupalKernel.php
            [line] => 717
            [function] => boot
            [class] => Drupal\Core\DrupalKernel
            [type] => ->
        )
    [23] => Array
        (
            [file] => /var/www/docroot/core/includes/utility.inc
            [line] => 43
            [function] => prepareLegacyRequest
            [class] => Drupal\Core\DrupalKernel
            [type] => ->
        )

So it seems composer is including SubProfileCommand.php which has lots of `use` statements for Console, which then throws errors, even though I'm just trying to load the site.

Comments

mcrittenden created an issue. See original summary.

bkosborne’s picture

I ran into something similar when trying to run a drush cache rebuild on a dev site:

root@7c6358ee7b90:/var/www/html/princeton# drush cr

Fatal error: Class 'Drupal\Console\Core\Command\Command' not found in /var/www/html/princeton/docroot/modules/contrib/lightning_core/src/Command/UpdateCommand.php on line 11
 [error]  Drush command terminated abnormally due to an unrecoverable error.
Error: Class 'Drupal\Console\Core\Command\Command' not found in /var/www/html/princeton/docroot/modules/contrib/lightning_core/src/Command/UpdateCommand.php, line 11
bendeguz.csirmaz’s picture

I could not reproduce this error, Lightning 4.0.0-alpha4 installed and loaded without errors.
Could you write down the exact steps to reproduce, please?

phenaproxima’s picture

Status: Active » Postponed (maintainer needs more info)
feilauren’s picture

I ran into this issue yesterday. It was resolved by adding drupal/console to the composer.json file in my project root. It looks like it used to exist as a dev requirement in the Lightning profile's Composer file but has been removed, which means that the patches made to fix this by moving it from a dev requirement up to a general requirement no longer work.

I did not test this solution but here is a similar issue, with patch:
https://www.drupal.org/project/lightning/issues/2955286

When attempting to install drupal/console, however, I ran into some aggressive conflicts, as seen here: https://github.com/hechoendrupal/drupal-console/issues/3885

This was resolved by deleting my vendor directory and lock file. Once that was working, the final problem is that the modules that I had attempted to install that triggered this issue in the first place were only partially installed. I removed them from Composer, installed, cleared caches, added back, re-enabled and it worked.

maticb’s picture

I ran into the same issue, it happened when trying to install a new module (media_pdf_thumbnail) it kept failing on UpdateCommand.php. As #5 I also had to remove vendor and composer.lock, then add drupal/console as core dependency and run drush en media_pdf_thumbnail after that.

I think the actual module I was installing here is irrelevant though.

bkosborne’s picture

Status: Postponed (maintainer needs more info) » Active

Ran into this again today. Not sure what exactly triggered it to happen. Not sure how I fixed this 9 months ago :)

For me it happens in local dev environment when running a drush cache clear (of drush cache):

root@6c927fd11b96:/var/www/html/princeton#  /var/www/html/princeton/vendor/bin/drush cache-clear drush --no-interaction -vvv --ansi
 [preflight] Config paths: /var/www/html/princeton/vendor/drush/drush/drush.yml,/var/www/html/princeton/drush/drush.yml
 [preflight] Alias paths: /var/www/html/princeton/docroot/drush/sites,/var/www/html/princeton/drush/sites
 [preflight] Commandfile search paths: /var/www/html/princeton/vendor/drush/drush/src,/var/www/html/princeton/drush
 [bootstrap] Starting bootstrap to max [0.23 sec, 8.32 MB]
 [debug] Trying to bootstrap as far as we can [0.23 sec, 8.32 MB]
 [bootstrap] Drush bootstrap phase: bootstrapDrupalRoot() [0.23 sec, 8.45 MB]
 [bootstrap] Change working directory to /var/www/html/princeton/docroot [0.23 sec, 8.45 MB]
 [bootstrap] Initialized Drupal 8.7.3 root directory at /var/www/html/princeton/docroot [0.23 sec, 8.45 MB]
 [bootstrap] Drush bootstrap phase: bootstrapDrupalSite() [0.24 sec, 8.97 MB]
 [bootstrap] Initialized Drupal site default at sites/default [0.24 sec, 8.97 MB]
 [bootstrap] Drush bootstrap phase: bootstrapDrupalConfiguration() [0.24 sec, 8.97 MB]
 [debug] Add service modifier [0.27 sec, 9.61 MB]
 [info] sql-query: SELECT 1; [0.27 sec, 9.69 MB]
 [info] Executing: mysql --defaults-file=/tmp/drush_dGRf50 --database=hr --host=db --port=3306 --silent -A < /tmp/drush_wlbijW > /dev/null [0.27 sec, 9.69 MB]
 [info] sql-query: SELECT 1 FROM key_value LIMIT 1; [0.28 sec, 9.69 MB]
 [info] Executing: mysql --defaults-file=/tmp/drush_3DR7Fa --database=hr --host=db --port=3306 --silent -A < /tmp/drush_6a2FS5 > /dev/null [0.28 sec, 9.69 MB]
 [bootstrap] Drush bootstrap phase: bootstrapDrupalDatabase() [0.29 sec, 9.69 MB]
 [bootstrap] Successfully connected to the Drupal database. [0.29 sec, 9.69 MB]
 [bootstrap] Drush bootstrap phase: bootstrapDrupalFull() [0.29 sec, 9.69 MB]
 [debug] Start bootstrap of the Drupal Kernel. [0.29 sec, 9.69 MB]
 [debug] Found drush.services.yml for cas Drush commands [1.29 sec, 13.35 MB]
 [debug] devel should have an extra.drush.services section in its composer.json. See http://docs.drush.org/en/master/commands/#specifying-the-services-file. [1.29 sec, 13.35 MB]
 [debug] Found drush.services.yml for features Drush commands [1.29 sec, 13.35 MB]
 [debug] Found drush.services.yml for lightning_core Drush commands [1.3 sec, 13.35 MB]
 [debug] Found drush.services.yml for search_api Drush commands [1.3 sec, 13.35 MB]
 [debug] views_slideshow_cycle should have an extra.drush.services section in its composer.json. See http://docs.drush.org/en/master/commands/#specifying-the-services-file. [1.3 sec, 13.35 MB]
 [debug] Found drush.services.yml for webform Drush commands [1.3 sec, 13.35 MB]
 [debug] pathauto should have an extra.drush.services section in its composer.json. See http://docs.drush.org/en/master/commands/#specifying-the-services-file. [1.3 sec, 13.35 MB]
 [debug] Get container builder [1.3 sec, 13.36 MB]
 [debugnotify] Service modifier alter. [1.31 sec, 13.52 MB]
 [debug] process drush.console.services console.command [1.47 sec, 18.27 MB]
 [debug] process drush.command.services drush.command [1.47 sec, 18.27 MB]
 [debugnotify] Found tagged service config.commands [1.47 sec, 18.28 MB]
 [debugnotify] Found tagged service config.export.commands [1.47 sec, 18.28 MB]
 [debugnotify] Found tagged service config.import.commands [1.47 sec, 18.28 MB]
 [debugnotify] Found tagged service batch.commands [1.47 sec, 18.28 MB]
 [debugnotify] Found tagged service cli.commands [1.47 sec, 18.28 MB]
 [debugnotify] Found tagged service drupal.commands [1.47 sec, 18.29 MB]
 [debugnotify] Found tagged service entity.commands [1.47 sec, 18.29 MB]
 [debugnotify] Found tagged service image.commands [1.47 sec, 18.29 MB]
 [debugnotify] Found tagged service language.commands [1.47 sec, 18.29 MB]
 [debugnotify] Found tagged service locale.commands [1.47 sec, 18.29 MB]
 [debugnotify] Found tagged service messenger.commands [1.47 sec, 18.29 MB]
 [debugnotify] Found tagged service queue.commands [1.47 sec, 18.29 MB]
 [debugnotify] Found tagged service role.commands [1.47 sec, 18.29 MB]
 [debugnotify] Found tagged service state.commands [1.47 sec, 18.3 MB]
 [debugnotify] Found tagged service twig.commands [1.47 sec, 18.3 MB]
 [debugnotify] Found tagged service user.commands [1.47 sec, 18.3 MB]
 [debugnotify] Found tagged service views.commands [1.47 sec, 18.3 MB]
 [debugnotify] Found tagged service watchdog.commands [1.47 sec, 18.3 MB]
 [debugnotify] Found tagged service pm.commands [1.47 sec, 18.3 MB]
 [debugnotify] Found tagged service theme.commands [1.47 sec, 18.3 MB]
 [debugnotify] Found tagged service sanitize.commands [1.47 sec, 18.3 MB]
 [debugnotify] Found tagged service sanitize.comments.commands [1.47 sec, 18.31 MB]
 [debugnotify] Found tagged service sanitize.sessions.commands [1.47 sec, 18.31 MB]
 [debugnotify] Found tagged service sanitize.userfields.commands [1.47 sec, 18.31 MB]
 [debugnotify] Found tagged service sanitize.usertable.commands [1.47 sec, 18.31 MB]
 [debugnotify] Found tagged service cas.commands [1.47 sec, 18.31 MB]
 [debugnotify] Found tagged service devel.command [1.47 sec, 18.31 MB]
 [debugnotify] Found tagged service features.commands [1.47 sec, 18.31 MB]
 [debugnotify] Found tagged service lightning_core.hooks [1.47 sec, 18.31 MB]
 [debugnotify] Found tagged service lightning_core.commands [1.47 sec, 18.32 MB]
 [debugnotify] Found tagged service search_api.commands [1.47 sec, 18.32 MB]
 [debugnotify] Found tagged service views_slideshow_cycle.commands [1.47 sec, 18.32 MB]
 [debugnotify] Found tagged service webform.commands [1.47 sec, 18.32 MB]
 [debugnotify] Found tagged service pathauto.commands [1.47 sec, 18.32 MB]
 [debug] process drush.command_info_alterer.services drush.command_info_alterer [1.47 sec, 18.32 MB]
 [debug] process drush.generator.services drush.generator [1.47 sec, 18.32 MB]

Fatal error: Class 'Drupal\Console\Core\Command\Command' not found in /var/www/html/princeton/docroot/modules/contrib/lightning_core/src/Command/UpdateCommand.php on line 11
 [error]  Drush command terminated abnormally due to an unrecoverable error.
Error: Class 'Drupal\Console\Core\Command\Command' not found in /var/www/html/princeton/docroot/modules/contrib/lightning_core/src/Command/UpdateCommand.php, line 11 [2.22 sec, 34.82 MB]
phenaproxima’s picture

I think I know why this is happening. I suspect that it's because Lightning Core exposes the command in its normal *.services.yml file, rather than console.services.yml.

Try moving the command's service definition into console.services.yml. If it works, post a patch and I will commit it :)

bkosborne’s picture

Yea, that's it I think. I made that change locally and got past the error.

bkosborne’s picture

Status: Active » Needs review
StatusFileSize
new828 bytes
phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

Perfect. Thanks, @bkosborne! I also tested this locally and confirmed this works, so it's RTBC. Assuming tests pass on CI, I will commit it.

bkosborne’s picture

StatusFileSize
new829 bytes

I'm on Lightning 4.2 at the moment, so here's a version of the patch that applies there. I'll hide the file though to not confuse others. Need it on d.o. for our devops workflow.

phenaproxima’s picture

Status: Reviewed & tested by the community » Fixed

Committed to Lightning Core 8.x-4.x and cherry-picked to 8.x-3.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.