megclaypool of Rootid
8/10/2018 - 11:37 PM

Drush Launcher (Instructions aimed for Mac users)

Ugh. Drush 9 can only be installed using composer require. Drush 8 can no longer be installed via homebrew (they removed it!) Soooo, here's how to set up Drush Launcher, which will use the Drush 9 you install in Drupal 8 projects using composer require, but fall back to a globally installed Drush 8 for old Drupal 7 projects.

SHIT, FUCK, AND DAMN!

Pantheon's Terminus is NOT currently compatible with Drush 9. If you have it installed in your project and you try to use terminus remote:drush your world will be a sad, sad place as your drush command goes down in flaming php-error wreckage...

So for now, just install Drush 8 globally. Rename the drush.phar to drush, and don't mess around with the rest of this till the Pantheon folks get this dealt with!

Drush Install Documentation

Latest Drush 8 Release

Drush Launcher

Install Drush 8 globally for older projects

  1. Find the latest version of Drush 8 and download the drush.phar
  2. In Terminal, navigate to the folder that contains your newly downloaded drush.phar (a quick way to do that is to type cd in the terminal window and then drag the folder that contains the drush.phar file from the finder onto the terminal window and drop it. Then hit enter.)
  3. Make it executable: chmod +x drush.phar
  4. Move the drush.phar into the proper directory in your path (Don't rename it!) sudo mv drush.phar /usr/local/bin/drush.phar

Install the Drush Launcher

  1. Download the latest drush.phar from the Drush Launcher Releases page
  2. Make it executable: chmod +x drush.phar
  3. Move the drush.phar into the proper directory in your path and rename it so the command drush calls the Drush Launcher: sudo mv drush.phar /usr/local/bin/drush
  4. Export an environment variable so Drush Launcher uses Drush 8 when not in a Drupal 8 site with Drush 9 installed export DRUSH_LAUNCHER_FALLBACK=/usr/local/bin/drush.phar
  5. Update Drush Launcher as needed: drush self-update

Install Drush 9 in Drupal 8 projects

  1. Navigate to /web in your D8 project (at least the way we're setting them up at Rootid).
  2. composer require drush/drush

Now just use drush as you used to in days of yore; if you're in a Drupal 8 project with Drush 9 installed locally, the Drush Launcher will find Drush 9 in the vendors folder and use it. Otherwise, the Drush Launcher will fall back to the global Drush 8 install