Installing Drush 9 for Drupal 8 the messy way.

Last night I attempted a migration of one of my oldest sites from Drupal 7 to Drupal 8. I was pretty impressed with the simplicity of the migration but using the migrate web interface proved to be a bit much for a site that has been in existence since 2004. There are tens of thousands users, nodes and comments and the web interface just takes too long.

So enter Drush. What is Drush? It is a command line interface for Drupal.

Now one of the problems with most documentation and tutorials is that they don’t present some of the gotchas that have nothing to do with the subject matter. Although I will likely write a cleaner version of a installing Drush 9 for Drupal tutorial. It thought I would keep it real as I walked through the Drush documentation.

I have Composer installed globally and in the /usr/local/bin directory.

My Drupal sites are organized in the home directories of the users on my server ie /home/username/public_html

I log into my server and go to the right directory

$ sudo su username
$ cd ~
cd public_html

Following the Drush documentation it instructs me to simply run:

$ composer require drush/drush
bash: composer: command not found

You can see this didn’t work. Why? Well let’s look.

If I look at my path for this user, you will see the directory where composer is installed is not in my path.

$ echo $PATH

Now I can solve this by adding /usr/local/bin to my path but I thought doing this the messy way might make for a better post so here is how I preceded.

Since I know the full path for composer I can use it.

$ /usr/local/bin/composer require drush/drush

Now Drush is installed.

The next line of the documentation reads, “you may call Drush via vendor/bin/drush.”

This may confuse you when you do cut and paste it in because it will spit out all the command options for Drush. I prefer:


$ vendor/bin/drush --version
Drush Commandline Tool 9.5.2

Yay it works. One caveat though. This only works if you are in the top level directory of you Drupal install. If you went down one level it would not work.

Now hopefully you can see how to use Drush even if you don’t have everything set up neatly to do so from the start.

Leave a Reply

Your email address will not be published. Required fields are marked *