How to manage multiple drupal 7/8 sites with multiple drush versions 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-&gt;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-&gt;bootstrap_drupal_database_validate() called at [phar:///usr/local/bin/drush/lib/Drush/Boot/DrupalBoot8.php:111]
#7  Drush\Boot\DrupalBoot8-&gt;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-&gt;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] =&gt; /usr/local/bin/drush,[1] =&gt; --alias-path=/Users/fanderson/.drush/sites,[2] =&gt; --root=/var/www/project-client.dev.example.net/current/web/public,[3] =&gt; --uri=project-client.dev.example.net,[4] =&gt; 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.
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.