drush-ops / drush

Drush is a command-line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those who spend their working hours hacking away at the command prompt.
https://www.drush.org
2.34k stars 1.08k forks source link

Executing `drush` results in fatal error #2959

Closed grasmash closed 7 years ago

grasmash commented 7 years ago

I'm executing the following command inside a virtual machine, where drush launcher is not installed, and drush is included on a project level via composer (9.0.0-beta4). PHP 7.1.9-1.

./vendor/bin/drush
PHP Fatal error:  Uncaught Symfony\Component\Console\Exception\InvalidArgumentException: Command name "" is invalid. in /var/www/blted8/vendor/symfony/console/Command/Command.php:666
Stack trace:
#0 /var/www/blted8/vendor/symfony/console/Command/Command.php(429): Symfony\Component\Console\Command\Command->validateName('')
#1 /var/www/blted8/vendor/symfony/console/Command/Command.php(60): Symfony\Component\Console\Command\Command->setName('')
#2 /var/www/blted8/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(55): Symfony\Component\Console\Command\Command->__construct('')
#3 /var/www/blted8/vendor/consolidation/annotated-command/src/AnnotatedCommandFactory.php(395): Consolidation\AnnotatedCommand\AnnotatedCommand->__construct('')
#4 /var/www/blted8/vendor/consolidation/annotated-command/src/AnnotatedCommandFactory.php(292): Consolidation\AnnotatedCommand\AnnotatedCommandFactory->createCommand(Object(Consolidation\AnnotatedCommand\Parser\CommandInfo), Object(Drush\CommandFiles\Core\BrowseCommands))
#5 [internal fu in /var/www/blted8/vendor/symfony/console/Command/Command.php on line 666

Fatal error: Uncaught Symfony\Component\Console\Exception\InvalidArgumentException: Command name "" is invalid. in /var/www/blted8/vendor/symfony/console/Command/Command.php on line 666

Symfony\Component\Console\Exception\InvalidArgumentException: Command name "" is invalid. in /var/www/blted8/vendor/symfony/console/Command/Command.php on line 666

Call Stack:
    0.0001     349944   1. {main}() /var/www/blted8/vendor/drush/drush/drush:0
    0.0005     350848   2. require('/var/www/blted8/vendor/drush/drush/drush.php') /var/www/blted8/vendor/drush/drush/drush:4
    0.0021     537520   3. drush_main() /var/www/blted8/vendor/drush/drush/drush.php:10
    0.0021     537520   4. drush_preflight_prepare() /var/www/blted8/vendor/drush/drush/includes/preflight.inc:38
    0.1124    6246776   5. drush_init_annotation_commands() /var/www/blted8/vendor/drush/drush/includes/preflight.inc:187
    0.1268    6464880   6. drush_init_register_command_files() /var/www/blted8/vendor/drush/drush/includes/preflight.inc:363
    0.1275    6475872   7. drush_add_command_instance() /var/www/blted8/vendor/drush/drush/includes/preflight.inc:379
    0.1276    6475872   8. drush_create_commands_from_command_instance() /var/www/blted8/vendor/drush/drush/includes/preflight.inc:388
    0.1276    6475872   9. Consolidation\AnnotatedCommand\AnnotatedCommandFactory->createCommandsFromClass() /var/www/blted8/vendor/drush/drush/includes/preflight.inc:394
    0.1350    6584856  10. Consolidation\AnnotatedCommand\AnnotatedCommandFactory->createCommandsFromClassInfo() /var/www/blted8/vendor/consolidation/annotated-command/src/AnnotatedCommandFactory.php:150
    0.1350    6585552  11. Consolidation\AnnotatedCommand\AnnotatedCommandFactory->createSelectedCommandsFromClassInfo() /var/www/blted8/vendor/consolidation/annotated-command/src/AnnotatedCommandFactory.php:283
    0.1351    6586664  12. array_map() /var/www/blted8/vendor/consolidation/annotated-command/src/AnnotatedCommandFactory.php:294
    0.1351    6586720  13. Consolidation\AnnotatedCommand\AnnotatedCommandFactory->Consolidation\AnnotatedCommand\{closure}() /var/www/blted8/vendor/consolidation/annotated-command/src/AnnotatedCommandFactory.php:294
    0.1351    6586720  14. Consolidation\AnnotatedCommand\AnnotatedCommandFactory->createCommand() /var/www/blted8/vendor/consolidation/annotated-command/src/AnnotatedCommandFactory.php:292
    0.1371    6657320  15. Consolidation\AnnotatedCommand\AnnotatedCommand->__construct() /var/www/blted8/vendor/consolidation/annotated-command/src/AnnotatedCommandFactory.php:395
    0.1372    6657320  16. Symfony\Component\Console\Command\Command->__construct() /var/www/blted8/vendor/consolidation/annotated-command/src/AnnotatedCommand.php:55
    0.1372    6657480  17. Symfony\Component\Console\Command\Command->setName() /var/www/blted8/vendor/symfony/console/Command/Command.php:60
    0.1372    6657480  18. Symfony\Component\Console\Command\Command->validateName() /var/www/blted8/vendor/symfony/console/Command/Command.php:429
grasmash commented 7 years ago

After some investigation, it looks like the annotated command package is not able to properly parse the drush command files.

$ composer info
acquia/blt                                     8.x-dev 3ea4b20 BLT
acquia/lightning                               2.2.0-alpha1    The best of Drupal, curated by Acquia
asm89/stack-cors                               1.1.0           Cross-origin resource sharing library and stack middleware
asm89/twig-lint                                1.0.2           Standalone twig linter.
behat/behat                                    v3.3.1          Scenario-oriented BDD framework for PHP 5.3
behat/gherkin                                  v4.5.1          Gherkin DSL parser for PHP 5.3
behat/mink                                     v1.7.1          Browser controller/emulator abstraction for PHP
behat/mink-browserkit-driver                   v1.3.2          Symfony2 BrowserKit driver for Mink framework
behat/mink-extension                           v2.2            Mink extension for Behat
behat/mink-goutte-driver                       v1.2.1          Goutte driver for Mink framework
behat/mink-selenium2-driver                    v1.3.1          Selenium2 (WebDriver) driver for Mink framework
behat/transliterator                           v1.2.0          String transliterator
bex/behat-extension-driver-locator             1.0.2           Driver locator tool for behat extensions
bex/behat-screenshot                           1.2.6           Extension for behat to help debug failing scenarios
bower-asset/cropper                            v2.3.4
bower-asset/dropzone                           v5.1.1
caxy/php-htmldiff                              v0.1.5          A library for comparing two HTML files/snippets and highlig...
chi-teck/drupal-code-generator                 1.19.0          Drupal code generator
composer/installers                            v1.4.0          A multi-framework Composer library installer
composer/semver                                1.4.2           Semver library that offers utilities, version constraint pa...
consolidation/annotated-command                2.7.0           Initialize Symfony Console commands from annotated command ...
consolidation/config                           1.0.2           Provide configuration services for a commandline tool.
consolidation/log                              1.0.3           Improved Psr-3 / Psr\Log logger based on Symfony Console co...
consolidation/output-formatters                3.1.11          Format text by applying transformations provided by plug-in...
consolidation/robo                             1.1.3           Modern task runner
container-interop/container-interop            1.2.0           Promoting the interoperability of container objects (DIC, S...
cweagans/composer-patches                      1.6.2           Provides a way to patch Composer packages.
dealerdirect/phpcodesniffer-composer-installer v0.4.3          PHP_CodeSniffer Standards Composer Installer Plugin
defuse/php-encryption                          v2.1.0          Secure PHP Encryption Library
dflydev/dot-access-data                        v1.1.0          Given a deep data structure, access data by dot notation.
dmore/behat-chrome-extension                   1.0.0           Behat extension for controlling chrome without selenium
dmore/chrome-mink-driver                       2.4.0           Mink driver for controlling chrome without selenium
dnoegel/php-xdg-base-dir                       0.1             implementation of xdg base directory specification for php
doctrine/annotations                           v1.4.0          Docblock Annotations Parser
doctrine/cache                                 v1.6.2          Caching library offering an object-oriented API for many ca...
doctrine/collections                           v1.4.0          Collections Abstraction library
doctrine/common                                v2.7.3          Common Library for Doctrine projects
doctrine/inflector                             v1.1.0          Common String Manipulations with regard to casing and singu...
doctrine/instantiator                          1.0.5           A small, lightweight utility to instantiate objects in PHP ...
doctrine/lexer                                 v1.0.1          Base library for a lexer that can be used in Top-Down, Recu...
drupal-composer/drupal-scaffold                2.3.0           Composer Plugin for updating the Drupal scaffold files when...
drupal/acquia_connector                        1.13.0          Allows Drupal to securely communicate with the Acquia Subsc...
drupal/coder                                   8.2.12          Coder is a library to review Drupal code.
drupal/cog                                     1.9.0
drupal/config_filter                           1.0.0           Config Filter allows other modules to interact with a Confi...
drupal/config_split                            1.1.0           Configuration filter for importing and exporting extra config
drupal/config_update                           1.4.0           Provides basic revert and update functionality for other mo...
drupal/consumers                               1.0.0-beta1     Declare all the consumers of your API
drupal/contact_storage                         1.0.0-beta9     Provides storage and edit capability for contact messages.
drupal/core                                    8.4.0-rc2       Drupal is an open source content management platform poweri...
drupal/crop                                    1.2.0           Provides storage and API for image crops.
drupal/ctools                                  3.0.0           Provides a number of utility and helper APIs for Drupal dev...
drupal/ctools_block                            3.0.0           Provides improvements to blocks that will one day be added ...
drupal/devel                                   1.0.0           Various blocks, pages, and functions for developers.
drupal/diff                                    1.0.0-rc1       Compares two entity revisions
drupal/dropzonejs                              1.0.0-alpha7    Drupal integration for DropzoneJS - An open source library ...
drupal/drupal-driver                           v1.2.1          A collection of reusable Drupal drivers
drupal/drupal-extension                        v3.3.1          Drupal extension for Behat
drupal/embed                                   1.0.0           Provide a framework for various different types of embeds i...
drupal/entity                                  1.0.0-beta1     Provides expanded entity APIs, which will be moved to Drupa...
drupal/entity_block                            1.0.0-alpha2    Let site administrators place content entities as blocks.
drupal/entity_browser                          1.3.0           Entity browsing and selecting component.
drupal/entity_embed                            1.0.0-beta2     Allows any entity to be embedded within a text area using a...
drupal/features                                3.5.0           Enables administrators to package configuration into modules.
drupal/image_widget_crop                       2.0.0           Provides an interface for using the features of the Crop API.
drupal/inline_entity_form                      1.0.0-beta1     Provides a widget for inline management (creation, modifica...
drupal/jsonapi                                 1.3.0           Provides a JSON API standards-compliant API for accessing a...
drupal/media_entity                            1.6.0           Provides a lean and simple way to store media on Drupal 8 s...
drupal/media_entity_document                   1.1.0           Local documents integration for Drupal Media entity.
drupal/media_entity_image                      1.2.0           Local images integration for Drupal Media entity.
drupal/media_entity_instagram                  1.4.0           Media entity Instagram provider.
drupal/media_entity_twitter                    1.3.0           Media entity Twitter provider.
drupal/memcache                                2.0.0-alpha4    High performance integration with memcache.
drupal/metatag                                 1.2.0           Manage meta tags for all entities.
drupal/openapi                                 1.0.0-alpha1    Creates OpenAPI specification for Drupal REST resources.
drupal/panelizer                               4.0.0           Allow any entity view mode to be rendered using a Panels di...
drupal/panels                                  4.2.0           Core Panels display functions; provides no external UI, at ...
drupal/panels_ipe                              4.2.0           Panels In-place editor.
drupal/pathauto                                1.0.0           Provides a mechanism for modules to automatically generate ...
drupal/qa_accounts                             1.0.0-alpha1    Creates dummy accounts to aid in testing. Never enable in p...
drupal/scheduled_updates                       1.0.0-alpha6    Create scheduled updates to field values on entities such c...
drupal/schemata                                1.0.0-alpha2    Provide schema definitions of Drupal entities for type vali...
drupal/schemata_json_schema                    1.0.0-alpha2    Provides a data models for entity types and bundles in JSON...
drupal/search_api                              1.4.0           Provides a generic framework for modules offering search ca...
drupal/seckit                                  1.0.0-alpha2    Enhance security of your Drupal website.
drupal/security_review                         1.x-dev 35ebae4 Site security and configuration review module.
drupal/shield                                  1.1.0           Creates a general shield for the site.
drupal/simple_oauth                            3.0.0-beta1     The Simple OAuth module for Drupal
drupal/token                                   1.0.0           Provides a user interface for the Token API and some missin...
drupal/video_embed_field                       1.5.0           A pluggable field type for storing videos from external vid...
drupal/views_infinite_scroll                   1.5.0           A pager which allows an infinite scroll effect for views.
drupal/workbench_moderation                    1.2.0           Provides moderation states for content
drush/drush                                    9.0.0-beta4     Drush is a command line shell and scripting interface for D...
easyrdf/easyrdf                                0.9.1           EasyRdf is a PHP library designed to make it easy to consum...
egulias/email-validator                        1.2.14          A library for validating emails
ezyang/htmlpurifier                            v4.9.3          Standards compliant HTML filter written in PHP
fabpot/goutte                                  v3.2.1          A simple PHP Web Scraper
geerlingguy/drupal-vm                          4.6.0           A VM for local Drupal development, built with Vagrant + Ans...
grasmash/drupal-security-warning               1.0.0           Warns users installing Drupal project versions not supporte...
grasmash/yaml-cli                              1.0.3           A command line tool for reading and manipulating yaml files.
grasmash/yaml-expander                         1.1.1           Expands internal property references in a yaml file.
guzzlehttp/guzzle                              6.3.0           Guzzle is a PHP HTTP client library
guzzlehttp/promises                            v1.3.1          Guzzle promises library
guzzlehttp/psr7                                1.4.2           PSR-7 message implementation that also provides common util...
instaclick/php-webdriver                       1.4.5           PHP WebDriver for Selenium 2
j7mbo/twitter-api-php                          1.0.6           Simple PHP Wrapper for Twitter API v1.1 calls
jakoch/phantomjs-installer                     2.1.1-p07       A Composer package which installs the PhantomJS binary (Lin...
jakub-onderka/php-console-color                0.1
jakub-onderka/php-console-highlighter          v0.3.2
jarnaiz/behat-junit-formatter                  v1.3.2          Behat 3 JUnit xml formatter
lcobucci/jwt                                   3.2.2           A simple library to work with JSON Web Token and JSON Web S...
league/container                               2.4.1           A fast and intuitive dependency injection container.
league/event                                   2.1.2           Event package
league/oauth2-server                           6.0.2           A lightweight and powerful OAuth 2.0 authorization and reso...
masterminds/html5                              2.3.0           An HTML5 parser and serializer.
mikey179/vfsStream                             v1.6.5          Virtual file system to mock the real file system in unit te...
mkalkbrenner/php-htmldiff-advanced             0.0.8           An add-on for the php-htmldiff library for comparing two HT...
nikic/php-parser                               v3.1.1          A PHP parser written in PHP
oomphinc/composer-installers-extender          v1.1.2          Extend the composer/installers plugin to accept any arbitra...
paragonie/random_compat                        v2.0.10         PHP 5.x polyfill for random_bytes() and random_int() from P...
pear/console_table                             v1.3.0          Library that makes it easy to build console style tables.
phpdocumentor/reflection-docblock              2.0.5
phpspec/prophecy                               v1.7.2          Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage                      2.2.4           Library that provides collection, processing, and rendering...
phpunit/php-file-iterator                      1.4.2           FilterIterator implementation that filters files based on a...
phpunit/php-text-template                      1.2.1           Simple template engine.
phpunit/php-timer                              1.0.9           Utility class for timing
phpunit/php-token-stream                       1.4.11          Wrapper around PHP's tokenizer extension.
phpunit/phpunit                                4.8.36          The PHP Unit Testing framework.
phpunit/phpunit-mock-objects                   2.3.8           Mock Object library for PHPUnit
psr/container                                  1.0.0           Common Container Interface (PHP FIG PSR-11)
psr/http-message                               1.0.1           Common interface for HTTP messages
psr/log                                        1.0.2           Common interface for logging libraries
psy/psysh                                      v0.8.11         An interactive shell for modern PHP.
se/selenium-server-standalone                  v2.53.1         Composer distribution of Selenium Server Standalone, the br...
sebastian/comparator                           1.2.4           Provides the functionality to compare PHP values for equality
sebastian/diff                                 1.4.3           Diff implementation
sebastian/environment                          1.3.8           Provides functionality to handle HHVM/PHP environments
sebastian/exporter                             1.2.2           Provides the functionality to export PHP variables for visu...
sebastian/global-state                         1.1.1           Snapshotting of global state
sebastian/recursion-context                    1.0.5           Provides functionality to recursively process PHP variables
sebastian/version                              1.0.6           Library that helps with managing the version number of Git-...
squizlabs/php_codesniffer                      2.9.1           PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and...
stack/builder                                  v1.0.4          Builder for stack middlewares based on HttpKernelInterface.
sunra/php-simple-html-dom-parser               v1.5.2          Composer adaptation of: A HTML DOM parser written in PHP5+ ...
symfony-cmf/routing                            1.4.1           Extends the Symfony2 routing component for dynamic routes a...
symfony/browser-kit                            v3.3.9          Symfony BrowserKit Component
symfony/class-loader                           v3.2.13         Symfony ClassLoader Component
symfony/config                                 v3.2.13         Symfony Config Component
symfony/console                                v3.2.13         Symfony Console Component
symfony/css-selector                           v3.3.9          Symfony CssSelector Component
symfony/debug                                  v3.3.9          Symfony Debug Component
symfony/dependency-injection                   v3.2.13         Symfony DependencyInjection Component
symfony/dom-crawler                            v3.3.9          Symfony DomCrawler Component
symfony/event-dispatcher                       v3.2.13         Symfony EventDispatcher Component
symfony/filesystem                             v3.3.9          Symfony Filesystem Component
symfony/finder                                 v3.3.9          Symfony Finder Component
symfony/http-foundation                        v3.2.13         Symfony HttpFoundation Component
symfony/http-kernel                            v3.2.13         Symfony HttpKernel Component
symfony/polyfill-iconv                         v1.5.0          Symfony polyfill for the Iconv extension
symfony/polyfill-mbstring                      v1.5.0          Symfony polyfill for the Mbstring extension
symfony/process                                v3.2.13         Symfony Process Component
symfony/psr-http-message-bridge                v1.0.0          PSR HTTP message bridge
symfony/routing                                v3.2.13         Symfony Routing Component
symfony/serializer                             v3.2.13         Symfony Serializer Component
symfony/translation                            v3.2.13         Symfony Translation Component
symfony/validator                              v3.2.13         Symfony Validator Component
symfony/var-dumper                             v3.3.9          Symfony mechanism for exploring and dumping PHP variables
symfony/yaml                                   v3.2.13         Symfony Yaml Component
textalk/websocket                              1.2.0           WebSocket client and server
tivie/php-os-detector                          1.0.0           A small utility library that detects the OS the server is r...
twig/twig                                      v1.34.4         Twig, the flexible, fast, and secure template language for PHP
webflo/drupal-finder                           1.0.0           Helper class to locate a Drupal installation from a given p...
webmozart/assert                               1.2.0           Assertions to validate method input/output with nice error ...
webmozart/path-util                            2.3.0           A robust cross-platform utility for normalizing, comparing ...
wikimedia/composer-merge-plugin                v1.4.1          Composer plugin to merge multiple composer.json files
zendframework/zend-diactoros                   1.6.0           PSR HTTP Message implementations
zendframework/zend-escaper                     2.5.2
zendframework/zend-feed                        2.8.0           provides functionality for consuming RSS and Atom feeds
zendframework/zend-stdlib                      3.1.0
grasmash commented 7 years ago

A bit confused here, there appear to be two browse commands in my drush package. One lives in /vendor/drush/drush/lib/Drush/CommandFiles/core/browseCommands.php and the other lives in /vendor/drush/drush/src/Commands/core/BrowseCommands.php.

The first does not appear to have a full set of annotations. For instance, it does not have a @command annotation. This causes drush to throw fatal error while registering commands.

grasmash commented 7 years ago

I am not sure how this happened, as I ran only typical composer commands, but it seems that somehow two versions of drush managed to live together in the same vendor subdirectory.

Executing:

rm -rf vendor/drush
composer install

resolved the issue.

AnaLaura-cellardoormedia commented 2 years ago

I have the same error updating a drupal website using lando and composer. The site was running with no errors until now. The last changes include updates to development.services.yml and development.settings.php. I destroyed all components and rebuild lando resulting in green vitals but twig errors on stable/templates/field that does not make any sense.