---
title: "Switching Drush Versions"
url: "/articles/switching-drush-versions"
type: article
date: 2015-07-15
updated: 2016-03-24
---

# Switching Drush Versions

#  Switching Drush Versions 

 Different versions of Drupal require different versions of Drush, hereâ&#128;&#153;s how to make the switch easily

 By

 [  Karen Stevenson   ](/about/karen-stevenson) 

 July 15, 2015

  

Drush is great! I canâ&#128;&#153;t manage Drupal without it. But now that Drupal 8 is nearing release Iâ&#128;&#153;ve run into a big problem. Drupal 8 requires the bleeding edge version of Drush, but that version of Drush wonâ&#128;&#153;t work with older Drupal sites. In particular, I was running into problems trying to switch between a Drupal 6 site and the Drupal 8 site Iâ&#128;&#153;m trying to migrate it into. Drupal 6 works with nothing later than Drush version 5, but Drupal 8 requires a minimum of Drush version 8! And in the meantime Iâ&#128;&#153;m still working on several Drupal 7 sites which have Drush scripts that only work with Drush version 6 or 7. What I needed was an easy way to switch versions of Drush for the task at hand.

I combed the web for instructions on how to switch Drush versions on a Mac and didnâ&#128;&#153;t find what I needed. But I did find several articles that had parts of the answer. So I stitched things together and came up with the following system based on Composer.

## 1) Install Composer

Composer is the recommended method of installing Drush these days, certainly for the bleeding edge version. Iâ&#128;&#153;ll need composer to work with Drupal 8, so this makes sense anyway. Itâ&#128;&#153;s pretty easy to install following the instructions at [https://getcomposer.org/doc/00-intro.md#globally.](https://getcomposer.org/doc/00-intro.md#globally)

I previously had Drush installed with homebrew and wanted to get rid of that installation, so I had to do this:

```
brew remove --force drush
```

Then I installed a default version of Drush, Drush version 7, globally:

```
composer global require drush/drush:7.*
```

## 2) Pick a Location

I decided to go whole hog and create a way to switch between every version I might need, Drush 5, 6, 7, or 8, by creating directories for each of these. I could do this anywhere, but the most logical place seemed to be in my user directory.

## 3) Install Drush 8

```
mkdir ~/drush8
cd ~/drush8
composer require drush/drush:dev-master
```

## 4) Install Drush 7

```
mkdir ~/drush7
cd ~/drush7
composer require "drush/drush:7.*"
```

## 5) Install Drush 6

```
mkdir ~/drush6
cd ~/drush6
composer require "drush/drush:6.*"
```

## 6) Install Drush 5

```
cd ~
wget "https:// github. com/drush-ops/drush/archive/5.10.0.zip"
unzip 5.10.0.zip
sudo mv drush-5.10.0 drush5
```

## 7) Alias The Directories

To make them switchable I created an alias for each. In bash.profile I added the following:

```
alias drush5='~/drush5/drush'
alias drush6='~/drush6/vendor/bin/drush'
alias drush7='~/drush7/vendor/bin/drush'
alias drush8='~/drush8/vendor/bin/drush'
```

Since I installed Drush version 7 globally, anytime I type â&#128;&#156;drushâ&#128;&#157; without a version modifier, it will default to using Drush 7. Because of that I could have skipped the installation of the Drush7 version above, but I decided I liked the idea of having both a global default (that I might change later) and a definite way to invoke version 7 that will work without knowing or caring what the global default is.

## 8) Test The Aliases

To test the finished system, I made sure the aliases work as designed. I opened a new terminal window (so it picks up the changes in the bash profile) and typed:

```
drush5 --version
drush6 --version
drush7 --version
drush8 --version
```

From this point on any time I need to run a drush script that uses a particular version of drush I just need to use my new aliases to do so:

```
drush5 status
drush6 cc all
drush7 sql-sync
```

## 9) Profit

Thatâ&#128;&#153;s it. Now I know I can control the drush version by adjusting my commands to invoke the right version.

The following articles provided fodder for this solution:

- <https://www.idelft.nl/nl/triquanta>
- <http://www.jpstacey.info/blog/2014-04-07/switching-between-drush-major-versions>
- <http://docs.drush.org/en/master/install/>

 Published in:

- [  Drupal Development   ](/topics/drupal-development)
- [  Technical Project Management   ](/topics/project-management)
- [  System Administration   ](/topics/system-administration)

 

   You must have JavaScript enabled to use this form.

## Get in touch with us

### Tell us about your project. We'd love to hear from you!

 First Name  

 Last Name  

 Your email address  

 Your organization  

 How you heard about us  

 Tell us more 

     Leave this field blank