Using Multiple Drush Version For All Users

Drush, is the wonderful command line utility to manage Drupal site. However, on some occasion, you will need to install different Drush version in your local development machine to test out different features.

Following the official installation guide, we're going to setup global accessible Drush installation. The benefit of using such method is that any user can run the Drush command. Note that I'm currently using Fedora Rawhide (F22) but this should be applicable to all GNU/Linux distros.

First, make sure you've already install the Git version control tool. If not, just install it.

$ sudo yum install git php php-pear
$ sudo pear install Console_Table

Next, we'll clone the Drush from the Github repository. Rather than following the convention of installing it in /usr/local directory, I opt for /opt directory to differentiate packages or software installed by distribution and myself. Although the Drush command still depends on PHP binary from the default distribution.

$ sudo git checkout 6.5.0
Note: checking out '6.5.0'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
HEAD is now at 0a7918a... Prep for 6.5.0

Later, we need to create the soft link to the drush command and verify that our link works. Instead of using /usr/local/bin, we'll put the symbolic link to /usr/bin directory. More on this later.

To switch another Drush version, for example version 5.1, we'll using the git checkout command again.

$ sudo git checkout 5.1.0
Previous HEAD position was 0a7918a... Prep for 6.5.0
HEAD is now at 1583e0d... Prep for 5.1
$ drush --version
drush version 5.1

How about the latest version of 7. As shown below, version 7 uses Composer to install all its dependencies.

$ sudo git checkout 7.0.0-alpha9
Previous HEAD position was 1583e0d... Prep for 5.1
HEAD is now at f10919a... Prep for 7.0.0-alpha9.
$ drush --version
Unable to load autoload.php. Drush now requires Composer in order to install its dependencies and autoload classes. Please see README.md

Installation of Composer, dependency management for PHP is straight forward although executing downloaded Bash script directly is not recommended.

About

Disclaimer

Opinions expressed here are my own and do not represent the views of my current or past employers.

All content provided in this blog is for informational purposes only. I cannot guarantee the accuracy or completeness of all information supplied here or found by following any link on this site and will accept no liability for any loss or damage incurred.