Last updated 16 May 2017. Created on 27 October 2010.
Edited by bhogue, rivimey, Senpai, bechtold. Log in to edit this page.

Homebrew is a package manager. It's a easy and flexible way to install UNIX tools Apple didn't include with OS X.

Installing Homebrew

If you haven't installed Homebrew, follow the the installation instruction for Homebrew. (Note the requirements listed. Recent versions of OS X don't ship with Xcode so you might need to install "xcode-select --install")

Preparing for Drush

After successful installation of Homebrew we need to be able to grab drush from git.

brew install git
brew update

This will install homebrew in your /usr/local folder, install git and link Homebrew to its git repository.

Installing Drush

Note Homebrew changed their repo structure! Read the "Background" section here for more information.

Tap the PHP formulae repo and its dependencies, and install Drush:

brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/php
brew install drush

This will also install Drush Make.

After that you can start running Drush on your installation. For example:

cd <em>/my/server/httpdocs/drupal</em>/sites/default
drush help
drush status

The 'cd' is there to change the current (working) directory for Drush. Change the path to the one appropriate for your site. It uses that directory to determine which Drupal site it is interacting with. You can instead use the '-r' and '-l' options to explicitly pass that information.

Consult the extensive documentation on the Drush website here.

For Drupal 7 sites you can use any version of Drush up to and including Drush 8. For Drupal 8 sites, Drush version 8 is the lowest version that is supported. To check the Drush version use:

brew info drush

Note for MAMP, XAMP etc users

MAMP, XAMP and similar package their own version of PHP and MySQL within the package. Using a version of PHP other than the MAMP one will probably result in PHP not being able to connect to the MAMP database via 'localhost'. This is because the non-MAMP PHP will look for a Unix socket in /var/mysql (or similar) and the actual socket is within the MAMP package directory, e.g. /Applications/MAMP/tmp/mysql.

There are a couple of ways around this:

  1. Configure your Drupal settings.php to use host and port 8889, which is the default network socket for MAMP (although it is also configurable in MAMP's preferences).
  2. Ensure you are using the MAMP PHP on the command line. If:

    which php

    returns something like "/usr/local/bin/php" or "/usr/bin/php", then Drush will by default use that version too.

    You can tell Drush to use a specific version of PHP using:

    export DRUSH_PHP=/Applications/MAMP/bin/php/php7.1.0/bin/php

    Change php7.1.0 for the version of php you are using from the browser. This command can be added to your ".bashrc" file to make it permanent (as for PATH, below).


    drush status --verbose

    to check whether things are working and help find issues. If Drush finds a configured and installed database and can use it, you will see a line "Drupal bootstrap: Successful"; if not, something is not working yet or Drupal has not been installed yet.

    You can make that version the default for command line use using the shell PATH variable. Add the following to the end of the file ".bashrc" in your home directory:

    export PATH=/Applications/MAMP/bin/php/php7.1.0/bin:${PATH}

    Refer to where is bashrc (askubuntu)for more information on .bashrc.

    Note that changing PHP version for the website using MAMP's console will not change the version used for Drush: you must manually change the version of PHP in your ".bashrc" file.

  3. It is not recommended, but you can continue to use the system version of PHP by changing the socket file that it expects to see:
    sudo mkdir -f /var/mysql
    sudo rm -f /var/mysql/mysql.sock
    sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock

    This creates a soft link (a pointer) from the name the system version of PHP uses to talk to MySQL, to the actual name that MAMP uses.

    This is not recommended because the system version of PHP may behave differently to the MAMP version (for example, PHP7 interprets files slightly differently to PHP5), so you may see strange bugs and differences which are hard to understand. Also, changing the softlink may affect other programs on your system adversely and may be changed by system updates and the like.

Looking for support? Visit the forums, or join #drupal-support in IRC.


aquariumtap’s picture

The curl link for installing homebrew seems to have changed. It is now:

ruby -e "$(curl -fsSLk"

reference (likely to be more up-to-date):

bcobin’s picture

Homebrew looks like it's Intel only, but if you're using MAMP Pro on a PowerPC Mac, I found that all I needed to do was extract Drush into my main sandbox folder and then copy and rename the example.drushrc.php (to drushrc.php) file into the same folder. It works on all my sandbox sites like a charm.

kostajh’s picture

trying to run drush gives me this error:

Could not open input file: /usr/local/lib/drush/drush.php

I have to run sudo drush to get it to work. How can I use drush without sudo when using Homebrew to install? I've only encountered this problem when using Homebrew to install drush.

zorp’s picture

For homwbrew to work correctly the folder /usr/local must be owned by your user accoount... sometime it change into being owned by root.

try running $ brew doctor
and it will probaly tell you that it can't write to /usr/local folder

mori’s picture

I get this response running "brew doctor":

Warning: /usr/bin occurs before /usr/local/bin
This means that system-provided programs will be used instead of those
provided by Homebrew. The following tools exist at both paths:


Consider amending your PATH so that /usr/local/bin
occurs before /usr/bin in your PATH.

Warning: Homebrew's sbin was not found in your path.
Consider amending your PATH variable so it contains:

Any suggestions what to do and how?

aagd’s picture

In Terminal try:

echo $PATH

to read what's in there. $PATH is set from both ~/.profile and ~/.bash_profile

for example my .profile includes this line:

export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
socketwench’s picture

If you are working with the development branch of Drupal core, you will need the git version of Drush. You can install that with homebrew by adding the --HEAD switch:

brew install --HEAD drush
basvredeling’s picture

This was most helpful! thank you

If you're already on an older version of drush and want to switch to drush dev and back here's how to:

$> brew unlink drush
$> brew install --HEAD drush

list the locally installed versions of drush

$> brew info drush

switch to an older version (if installed in the list retrieved by brew info drush)

$> brew switch drush 6.2.0
zetagraph’s picture

Thank you and @socketwench for the tip, worked like a charm. Just had to Specify `--HEAD` in uppercase to build from trunk.

basvredeling’s picture

Corrected it... thanks

catchlight’s picture

I have drush in my usr/bin/drush directory, however...
drush help & drush status give me the following

Unable to load autoload.php. Drush now requires Composer in order to install its depedencies and autoload classes. Please see

I've installed Homebrew but it looks like it needs a whole bunch of Xcode stuff which is beyond my skill level at this stage.
Can anyone help out?

basvredeling’s picture

Xcode shouldn't scare you. It's free, easy to install, and mac native. You probably need the command line tools from xcode. Follow the corresponding Readme. Also, the first answer in this stackoverflow thread is clear and concise:
It should be sufficient to solve your xcode problems.

Now, to solve your problems with composer is a bit more complex. It really depends how you installed php and where you're calling drush. If you've installed homebrew-php you can install composer system-wide with brew install composer. You could also call composer locally via php and build the drush dependencies locally. Or you might need to set the proper php location in bash.
Go to the proper installation directory of drush (follow the symlinks). If there is a composer.json file in the install directory (which there probably is) run php composer.phar install in this directory. (make sure you use the correct php).

More composer installation suggestions on:

best of luck.

mccrodp’s picture

I can use "drush dl " and "drush cc all" etc., but nothing requiring a higher bootstrap level. I have tried both versions and I have tried following the instructions at the link which is provided in the drush error message.

Drush was not able to start (bootstrap) the Drupal database.

I have also added an alias to a file aliases.drushrc.php in ~/.drush folder. The alias is recognised but the bootstrap error remains.

This is similar to the error described on Drupal Answers, that is presently unanswered.

For other people using AMPPS you need to link to /Applications/AMPPS/mysql/tmp/mysql.sock

sudo ln -s /Applications/AMPPS/mysql/tmp/mysql.sock /var/mysql/mysql.sock

EDIT: I changed to MAMP due to other reasons, but had the same drush issues, so the solution I found might be the same for both. Add your PATH to AMPPS/MAMP php executable first, in .bash_profile or similar.

mercergirl’s picture

That command is missing the tail end (at least in my browser) and not including the final :$PATH will reset your path without including your default PATH.

The complete command is:
export PATH=/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php/php5.3.28/bin:/usr/local/bin:$PATH

It is shown in full on this page with the comment input box, but the normal page has a right sidebar that covers part of the code.

Now, does anybody know how to reset the $PATH variable back to default on a macbook pro?

mccrodp’s picture

I've updated the export commands so that they are visible.

You can delete your path export custom rules from your .bash_profile. Then open a new terminal and check "echo $PATH".
Or take a look at this post:

mercergirl’s picture

I actually had to reboot and found that my PATH had been reset to the default by the system. With my PATH trashed I had no bash commands, nothing to work with. Good to know that as always, mac knows best!

AniG’s picture

I am running yosemite 10.10 on mbpr 2013

brew --version 0.9.5

I cloned the taps mentioned. When I tried brew install drush, I got:

$ brew install drush
Error: No available formula for drush
Searching formulae...
drush4 drush5
Searching taps...

Any help?

jtjones23’s picture

Hi AniG,

I'm getting the same error message you were getting . Did you ever find a solution?

dshumaker’s picture

Hi AniG,
I tried with brew 0.9.5 as well and got this funky error I won't post here because I've closed the window already, but I feel your pain and so will try to help you.

Turns out brew works with "fuller" paths. Meaning it's not "brew install drush" but "brew install homebrew/php/drush". However that's not the end of the story. I had to do several other things.

1.brew install composer
2. brew update
brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/php
brew unlink drush
brew install --HEAD drush
brew switch drush HEAD

And then finally I had to create this alias in my .bash_profile file.

alias drush="/Applications/MAMP/bin/php/php5.4.34/bin/php /usr/local/Cellar/drush/HEAD/libexec/drush.php"

Good luck and God speed. I hope that helps you. I can't live without drush and I don't think others should either! :)

ps. I'm also running yosemite with MacBook Pro.

rajat.dkte’s picture

Hi, dshumaker

thanks, its worked for me.
I am also using MacBook Pro(yosemite).

jtjones23’s picture

Thanks, I just had to run "brew install homebrew/php/drush" and the installation worked for me. I'm also running Yosemite.

rakesh.gectcr’s picture

brew install homebrew/php/drush

worked for me in Yosemite 10.10.3

1. brew install composer
2. brew update
3. brew install homebrew/php/drush

Rakesh James

libruce’s picture

Thanks AniG, I've added alias to drush

$ alias drush
alias drush='/Applications/MAMP/bin/php/php5.6.10/bin/php /usr/local/Cellar/drush/HEAD/libexec/drush.php'

but still having errors in drupal8 sites

:drupal-8.0.2 bruce$ drush status
Drush command terminated abnormally due to an unrecoverable error.                                                                                                                               [error]
Error: Call to undefined function conf_path() in /usr/local/Cellar/drush/HEAD/libexec/lib/Drush/Boot/DrupalBoot.php, line 383

in non-drupal folder, drush works good.

$ drush status
 PHP configuration      :  /Applications/MAMP/bin/php/php5.6.10/conf/php.ini
 PHP OS                 :  Darwin
 Drush script           :  /usr/local/Cellar/drush/HEAD/libexec/drush.php
 Drush version          :  8.0-dev
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :  /Users/bruce/.drush/libruce.aliases.drushrc.php

Any idea about the error?

alex_drupal_dev’s picture

Warning: Do not attempt this with osx 10.6.8.

I tried that is all heck broke loose. Just upgrade to new OSX before doing this.

kwatahfili’s picture

I'm getting Error: No such file or directory - drush.bat at brew install --HEAD drush

This tutorial is no longer clear on what those who do not need git version are to do. If I am unable to successfully install git version, how should I proceed?

brew install drush
Ignore the switch?

cd into where to do composer install? It is failing just inside of Cellar/drush

jtjones23’s picture

Try brew install homebrew/php/drush

kwatahfili’s picture

Thanks for the reply jtjones...

Warning: homebrew/php/drush-8.1.3 already installed

I ran brew uninstall drush and then tried it again..

I tried variations of what others in the comments without success. Cannot successfully get HEAD

Error: drush does not have a version "HEAD" in the Cellar.
Versions available: .git, 8.1.3, commands, docs, examples, includes, lib, misc, tests, vendor

Edit: I had come back to this point because I thought that my drush install had failed when indeed it had not. My issue was related to mysql sockets (MAMP Application PATH issues) I believe and I resolved it using other threads. Still curious why git isn't working, but at least I have functioning drush now.

mikhail.krainiuk’s picture


I use brew unlink drush instead brew uninstall drush. Maybe we need another uninstall command?
These commands work correctly for me:

brew unlink drush
brew install homebrew/php/drush
remory’s picture

This article is outdated. When you follow the instructions for Drush 6, you will get Drush 8. What I really need is Drush 6. Thank you.

rivimey’s picture

remory, homebrew at present only provides builds of Drush 8, which can manipulate Drupal 6, Drupal 7 and Drupal 8 sites.

Instructions for how to install other versions are available on the drush website (

DannyLondon’s picture