0

We manage a bunch of Drupal 7 sites and a few Drupal 8 sites. I have been trying to workout the change to Drush 9 on the Drupal 8 sites and I have hit a roadblock.

For some reason when I try to use a local drush alias to contact the site it fails. If fails slightly differently for all the different contexts.

Locally, I have Drush 8.1.15 installed globally with composer, Drush 9.2.1 in my drupal site. I have a yaml alias and a php alias both local and remote.

On the dev server Drush 8.1.10 was installed with the phar download.

$ ./vendor/drush/drush/drush @project-client.dev st
Missing argument 2 for Drush\Sql\SqlBase::__construct() SqlBase.php:34                                                                            [warning]
#0  Drush\Drush::getContainer() called at [/mnt/www/project-client.dev.example.net/repo/vendor/drush/drush/src/Drush.php:193]
#1  Drush\Drush::service(config) called at [/mnt/www/project-client.dev.example.net/repo/vendor/drush/drush/src/Drush.php:238]
#2  Drush\Drush::config() called at [/mnt/www/project-client.dev.example.net/repo/vendor/drush/drush/src/Drush.php:274]
#3  Drush\Drush::simulate() called at [/mnt/www/project-client.dev.example.net/repo/vendor/drush/drush/src/Sql/SqlBase.php:221]
#4  Drush\Sql\SqlBase->query(SELECT 1;) called at [phar:///usr/local/bin/drush/includes/environment.inc:393]
#5  drush_valid_db_credentials() called at [phar:///usr/local/bin/drush/lib/Drush/Boot/DrupalBoot.php:462]
#6  Drush\Boot\DrupalBoot->bootstrap_drupal_database_validate() called at [phar:///usr/local/bin/drush/lib/Drush/Boot/DrupalBoot8.php:111]
#7  Drush\Boot\DrupalBoot8->bootstrap_drupal_database_validate() called at [phar:///usr/local/bin/drush/includes/bootstrap.inc:430]
#8  drush_bootstrap_validate(4) called at [phar:///usr/local/bin/drush/includes/bootstrap.inc:507]
#9  drush_bootstrap_max() called at [phar:///usr/local/bin/drush/includes/bootstrap.inc:456]
#10 drush_bootstrap_to_phase(-2) called at [phar:///usr/local/bin/drush/lib/Drush/Boot/BaseBoot.php:59]
#11 Drush\Boot\BaseBoot->bootstrap_and_dispatch() called at [phar:///usr/local/bin/drush/includes/preflight.inc:66]
#12 drush_main() called at [phar:///usr/local/bin/drush/includes/startup.inc:458]
#13 drush_run_main(, /, Phar detected. Proceeding to drush_main().) called at [phar:///usr/local/bin/drush/includes/startup.inc:365]
#14 drush_startup(Array ([0] => /usr/local/bin/drush,[1] => --alias-path=/Users/fanderson/.drush/sites,[2] => --root=/var/www/project-client.dev.example.net/current/web/public,[3] => --uri=project-client.dev.example.net,[4] => st)) called at [phar:///usr/local/bin/drush/drush:114]
#15 require(phar:///usr/local/bin/drush/drush) called at [/usr/local/bin/drush:10]
PHP Fatal error:  Declaration of Drush\Command\DrushInputAdapter::hasParameterOption() must be compatible with Symfony\Component\Console\Input\InputInterface::hasParameterOption($values, $onlyParams = false) in phar:///usr/local/bin/drush/lib/Drush/Command/DrushInputAdapter.php on line 27
Drush command terminated abnormally due to an unrecoverable error.                                                                                [error]
Error: Declaration of Drush\Command\DrushInputAdapter::hasParameterOption() must be compatible with
Symfony\Component\Console\Input\InputInterface::hasParameterOption($values, $onlyParams = false) in
phar:///usr/local/bin/drush/lib/Drush/Command/DrushInputAdapter.php, line 27
Connection to project-client.dev.example.net closed.

It looks to me as though it is attempting to run the global drush. How do I stop that? There are Drupal 7 sites on this dev server as well.

3
  • 1
    FYI - Despite Drush.org's docs, you do not need Drush 9 with Drupal > 8.4. Drupal's 8.4 docs clearly states that it works with Drush > 8.14. I've been using Drush 8.15 with Drupal 8.4.x with no problems. Just globally install the latest Drush 8 and don't bother with 9.
    – CG Monroe
    Mar 2, 2018 at 20:32
  • That works too, so as of right now the recommendation is to stay with drush 8. Mar 2, 2018 at 21:56
  • Still, this looks like a bug in the phar detection. Mar 2, 2018 at 21:56

1 Answer 1

0

I assume the command above is run locally and it connects to the dev server? On the dev server you have the phar-installed global Drush 8 and the site-local Drush 9. From the debug backtrace you see that it starts with launching the global Drush 8 and then at the end it uses some functions from the site-local Drush since those are included when Drupal 8 bootstraps. Not strange that it doesn't work. And to make it even worse the: The phar-installed global Drush is too old - Drush 8.14 is clearly needed.

It might work to upgrade the phar-installed Drush 8 to 8.15, but why not use Drush Launcher (which is recommended) and install in globally instead of Drush. It even supports a fallback to a globally installed Drush of your liking.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.