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

Error running twig:unused #5329

Closed
rt3me opened this issue Dec 6, 2022 · 2 comments
Closed

Error running twig:unused #5329

rt3me opened this issue Dec 6, 2022 · 2 comments

Comments

@rt3me
Copy link

rt3me commented Dec 6, 2022

Describe the bug
I get an error when I run:

drush twig:unused --field=template /var/www/proect_name/docroot/themes/custom/theme_name

To Reproduce
In local dev environment cd to a Drupal project, execute above command changing path argument as needed to point to a custom theme.

Expected behavior
Expected a list of unused twig templates.

Actual behavior
Drush listed the total number of twig templates found (not unused templates), then output the error:

[notice] Found 247 templates [error] Error: Call to a member function generateKey() on bool in Drush\Drupal\Commands\core\TwigCommands->unused() (line 89 of /var/www/PUB/vendor/drush/drush/src/Drupal/Commands/core/TwigCommands.php) #0 [internal function]: Drush\Drupal\Commands\core\TwigCommands->unused() #1 /var/www/PUB/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array() #2 /var/www/PUB/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback() #3 /var/www/PUB/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter() #4 /var/www/PUB/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(350): Consolidation\AnnotatedCommand\CommandProcessor->process() #5 /var/www/PUB/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute() #6 /var/www/PUB/vendor/symfony/console/Application.php(1027): Symfony\Component\Console\Command\Command->run() #7 /var/www/PUB/vendor/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand() #8 /var/www/PUB/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun() #9 /var/www/PUB/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run() #10 /var/www/PUB/vendor/drush/drush/src/Runtime/Runtime.php(48): Drush\Runtime\Runtime->doRun() #11 /var/www/PUB/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run() #12 /var/www/PUB/vendor/drush/drush/includes/preflight.inc(18): require('/var/www/PUB/ve...') #13 phar:///usr/local/bin/drush/bin/drush.php(143): drush_main() #14 /usr/local/bin/drush(14): require('phar:///usr/loc...') #15 {main}. Error: Call to a member function generateKey() on bool in /var/www/PUB/vendor/drush/drush/src/Drupal/Commands/core/TwigCommands.php on line 89 #0 [internal function]: Drush\Drupal\Commands\core\TwigCommands->unused() #1 /var/www/PUB/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array() #2 /var/www/PUB/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback() #3 /var/www/PUB/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter() #4 /var/www/PUB/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(350): Consolidation\AnnotatedCommand\CommandProcessor->process() #5 /var/www/PUB/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute() #6 /var/www/PUB/vendor/symfony/console/Application.php(1027): Symfony\Component\Console\Command\Command->run() #7 /var/www/PUB/vendor/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand() #8 /var/www/PUB/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun() #9 /var/www/PUB/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run() #10 /var/www/PUB/vendor/drush/drush/src/Runtime/Runtime.php(48): Drush\Runtime\Runtime->doRun() #11 /var/www/PUB/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run() #12 /var/www/PUB/vendor/drush/drush/includes/preflight.inc(18): require('/var/www/PUB/ve...') #13 phar:///usr/local/bin/drush/bin/drush.php(143): drush_main() #14 /usr/local/bin/drush(14): require('phar:///usr/loc...') #15 {main} Error: Call to a member function generateKey() on bool in Drush\Drupal\Commands\core\TwigCommands->unused() (line 89 of /var/www/PUB/vendor/drush/drush/src/Drupal/Commands/core/TwigCommands.php). [warning] Drush command terminated abnormally.

Workaround
No workarounds that I am aware of.

System Configuration

Q A
Drush version? 10.6.2 (please be specific, and try latest release)
Drupal version? 9.4.5
PHP version 7.4.3
OS? Ubuntu 20.04

Additional information
Add any other context about the problem here.

@weitzman
Copy link
Member

weitzman commented Dec 6, 2022

Drush 10 is no longer supported.

@ChrisScrumping
Copy link
Contributor

You need to enable your cache for this command to work.

This error is still shown in Drush 12/13 if the cache is disabled, I created a PR that would hopefully provide a better error.

#5962

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

3 participants