How to install Drush 8 globally on MacOSX with composer

What is Drush?

Drush is a command line shell and scripting interface for Drupal. It allows you to control, manipulate and administer your Drupal websites fast and easy. Drush is a very useful tool as it allows you to perform various admin tasks using a simple command/s in the terminal, replacing the need for several clicks and page refreshes in the UI.

Composer

This tutorial assumes that you already have composer installed globally on your MacOSX.

Installing Drush via Composer

To install Drush 8 run the command below:

composer global require drush/drush:"8.*"

If you get a popup requiring you to install other additional tools such as Xcode developer tools, install them.

Add Drush to the system PATH

To run Drush from anywhere on our system we need to add the new Drush installation to our system path. To do this run the command below to edit .bash_profile:

vi ~/.bash_profile

then press i to paste the line below:

export PATH="$HOME/.composer/vendor/bin:$PATH"

to save press “esc” , type :wq to save.

Run the command below to load the .bash_profile file without having to restart the terminal:

source ~/.bash_profile

At this point if you type drush –version and press enter you should see that you have Drush version: 8.0.2 installed.

Drush 8 end of life (EOL) is still to be determined (at the time this article was published) but is expected to be jointly with Drupal 7 EOL.

Note

If you choose to have a Drush 9+ version please take note of the information below.

Old alias files such as example.aliases.drushrc.php no longer load in Drush 9+. Drush 9+ cannot run commandfiles from Drush 8 and below (e.g. sample.drush.inc). Also note that alias and config files use a new .yml format in Drush 9.