megclaypool
8/8/2018 - 11:35 PM

Drush Launcher (Instructions aimed for Mac users)

[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 and hold off on the Drush Launcher and Drush 9. Jason wants to keep the composer.json file representative of the live environment, so if you need to install Drush 9 for some reason, go back and uninstall it before pushing your changes up to Pantheon.

Drush Install Documentation

Latest Drush 8 Release

Drush Launcher

Install Drush 8 globally for older projects

  1. cgr drush/drush:8.x

  2. Ignore the rest of this...

  3. Find the latest version of Drush 8 and download the drush.phar

  4. 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.)

  5. Make it executable: chmod +x drush.phar

  6. 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

** # power-users - Nov 19, 2018

Brian Weaver [1:28 PM] is shipping a drush 9 with a d8 site codebase still problematic on pantheon

Greg Anderson [6:36 PM] @bweaver We have dark-deployed Drush 9 on the platform. It works, but with some limitations.

  • If you put Drush 9 in your Composer-managed Drupal 8 site, then the "Status" tab on the dashboard will stop working. This is innocuous, except that you won't get status / site audit reports any longer.
  • Alternatively, you may try removing Drush from your Composer-managed site completely, and instead put drush_version: 9 in your pantheon.yml. If you do this, the site audit function should still work. Drush 9 is not supported yet, though. If you have problems, you may report them, but you might need to go back to Drush 8.