-1

I use a Mac for Drupal development and am a long time user of Drush.

Getting ready to develop a new Drupal 8 site and installed via "Option A" as described https://www.drupal.org/docs/develop/using-composer/using-composer-to-manage-drupal-site-dependencies

Following those instructions "out of the box", I wind up with a Drush 9.x instance inside of the Drupal 8 repository.

It is my understanding that Drush 9 won't support Drupal 7. So, I'm forced to have multiple versions of Drush unless I run one global instance of Drush 8.x. At least so it seems to me.

I'm also trying to make the shift to composer and installed Drush 8 as documented here.

And sadly, that instance breaks unless I list the mysql host as "127.0.0.1" (instead of localhost). And if I do that, Drupal breaks.

So - first question: 1) What is are the recommendations for Drush installation on a Mac running multiple versions of Drupal. Is it preferred to run on global instance? (Drush 8.x) - or leverage composer to install Drush locally within each Drupal instance.

2) Why (maybe out of the scope of this discussion) do I suddenly get an error installing Drush 8 using composer on my Drupal 7 instance? Drupal 8 fails as well, but a different error.

  • 1
    You can add Drush using composer composer require drush/drush. Then you can install the Drush Launcher, which will call the local drush in whatever project you are working on. – Jaypan Jun 19 '18 at 2:11
  • Thank you for the idea. I believe this is the code you're referring to (github.com/drush-ops/drush-launcher). Actually - I tried that but will look more closely at that option. – sea26.2 Jun 19 '18 at 4:30
2

You can run Drush 8 and Drush 9 at the same time.

Drush 8

Install Drush 8 globally:

# Browse to https://github.com/drush-ops/drush/releases and download the drush.phar attached to the latest 8.x release.

# Test your install.
php drush.phar core-status

# Rename to `drush` instead of `php drush.phar`. Destination can be anywhere on $PATH. 
chmod +x drush.phar
sudo mv drush.phar /usr/local/bin/drush

# Optional. Enrich the bash startup file with completion and aliases.
drush init

Reference http://docs.drush.org/en/8.x/install/

Drush 9

Use a composer based Drupal 8 scaffold which contains Drush 9:

composer create-project drupal-composer/drupal-project:8.x-dev some-dir --stability dev --no-interaction

Reference https://www.drupal.org/docs/develop/using-composer/using-composer-to-manage-drupal-site-dependencies

Running Drush

You don't need a launcher to run drush, because the global Drush 8 acts as one if it finds a locally installed Drush. So you can install a different Drush version for each Drupal site and have always Drush 8 as fallback globally. But I wouldn't recommend to install Drush 8 locally, in my experience the current Drush 8 works downloaded as phar file the most reliable. Ignore all older instructions how to install Drush by composer.

BTW if you still have a non composer based Drupal 8 site, the global Drush 8 works for Drupal versions > 8.3 as well, despite that it's not officially listed in the compatibility list. And you need Drush 8 to manage a Drupal 8 site without composer, because in Drush 9 the tools to manage Drupal without composer have been removed.

  • I'm marking this as answered. Although it really didn't address the question about the relevance of being forward compatible (e.g., installing/maintaining DRUSH with COMPOSER). completely purged all instances and reference for and to the old DRUSH and reinstalled 8 per above. Didn't work. Then; configured per docs.drush.org/en/7.x/configure. These are V7 instructions and should be included for V8. That got things working. Then, I installed Drupal 8 per github.com/drupal-composer/drupal-project. Both Drush 8.x and 9.x are working. – sea26.2 Jun 19 '18 at 20:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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