Drush can be installed on a Mac using the Homebrew package manager, or manually using the following steps.

Please see the next link for the most updated instruction

https://docs.drush.org/en/8.x/install-alternative/

Download and unpack Drush

From the Drush GitHub Repository, clone or download the zip file. Make sure to check the 'Drupal Compatibility' section found in the Read Me at Resources: Installing and Upgrading, to see which version of Drush is currently recommended. Unpack it into your home directory or a directory below your home directory. For example, if your home directory is /Users/myusername, unpacking the tar.gz or zip file there will create a folder /Users/myusername/drush.

Download and install Composer

Drush now requires Composer in order to install its dependencies and autoload classes.

In terminal:
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

From the Drush directory run composer install.
composer install

Tell OS X where to find Drush

To tell your system where to find the Drush program, you can either:

  • add the directory where Drush was downloaded to your PATH by updating your Bash or Zsh profile; or
  • create a symbolic link from the Drush program to a directory in your PATH.

Add Drush directory to your PATH

The PATH shell variable tells OS X where to find programs that are run from the command line. You can update your PATH by editing the file .bash_profile (if you are using the Bash shell) or .zprofile (if you are using Zsh). These files are hidden files (name beginning with a dot) so they will usually not appear in the Finder.

To edit the profile file with the Nano text editor, open Terminal and type

nano ~/.bash_profile

and add the following line to the end of the file:

export PATH=$PATH:/Users/myusername/drush

Replace /Users/myusername/drush with the name of the directory where you unpacked Drush.

Alternative export path would be:

export PATH="$HOME/drush:$PATH"

Note: You may have to type source ~/.bash_profile if Drush isn't immediately usable. The source command tells OSX to update it's records with any changes made to ~/.bash_profile (or ~/.profile).

Symbolic link

In terminal:

cd /usr/local/bin
ln -s /Users/myusername/drush/drush

Replace /Users/myusername/ with the name of the directory where you unpacked Drush.

You may need to quit and restart Terminal after completing these instructions before running any drush commands.

(See video: http://youtu.be/TCg02d4am_Q)

Comments

ziobudda’s picture

Hi, I have followed your instruction but when I exec "drush -v" I receive:

$ drush -v
Unable to load autoload.php. Drush now requires Composer in order to install its dependencies and autoload classes. Please see README.md

I have tried with:

$ cd
$ cd drush
$ sudo /bin/bash
# composer install

But (after composer installation) I get always the same error.

Any help ?

M.

Freelancer Senior Drupal Developer -- http://www.ziobuddalabs.it

ranelpadon’s picture

I've encountered the same error, but as indicated here, I've tried these two and it's working now:

$ composer self-update
$ ln -s /path/to/drush/drush /usr/bin/drush
mericone’s picture

Hi,

I had to change to the drush directory and tell composer to start installing:

cd /path/to/drush
composer install

Then it worked for me (as mentioned above).

pal4life’s picture

I tried the various solutions on this page but still see this issue
'Unable to load autoload.php. Drush now requires Composer in order to install its dependencies and autoload classes. Please see README.md'

Composer seems to have been installed currently then unsure why this message still comes up.

brassman66’s picture

Try running 'composer update'.

karenann’s picture

This worked for me! Thank you!

bavarian’s picture

sudo mv composer.phar /usr/bin/composer
gives me
mv: rename composer.phar to /usr/bin/composer: Operation not permitted

stuck there and don't know how to continue

sprocketman’s picture

Have a look at this: http://apple.stackexchange.com/questions/101328/file-cant-be-moved-by-ro... Specifically the answer about the new security layer in El Capitan. I haven't tried this myself, so no guarantees :-).

kbrinner’s picture

I had the same issue, couldn't move the new composer version (drush stopped working after I upgraded to El Capitan). However, when I ran which composer I got /usr/local/bin/composer, so just went ahead with the instructions:

From the drush directory run composer install.
composer install

and everything worked fine after that.

Anonymous’s picture

I suggest ditching SIP all together. It solved all my "El Capitan" problems, including recording hardware now working.

You can't do it from the system. You need to go to the recovery screen to do it. They call it "rootless" , like "ruthless" for osx.

Steps to go "rootless"

1. Reboot.

2. After you hear startup chime press "command + R"

3. When the recovery screen opens up pull down top menu "utilities"

4. In the "utilities" menu choose "Terminal"

5. In terminal run this command ; csrutil disable; reboot

Thats all. Then no more OSX security crap messing up your day in El Capitan.

Sarvasri’s picture

I've been trying for 2 days to figure out how to install Composer and Drush.
This page on installing needs a complete rework.
Nothing works.

From the first command: curl -sS https://getcomposer.org/installer | php
I get the following:

Some settings on your machine may cause stability issues with Composer.
If you encounter issues, try to change the following:

The OpenSSL library (0.9.8zc) used by PHP does not support TLSv1.2 or TLSv1.1.
If possible you should upgrade OpenSSL to version 1.0.1 or above.

Downloading...

Composer successfully installed to: /Users/Sarvasri/composer.phar
Use it: php composer.phar

Assuming it got installed, though using and outdated version of OpenSSL

I try the next command:
sudo mv composer.phar /usr/bin/composer
.. after entering my password, I get:
mv: rename composer.phar to /usr/bin/composer: Operation not permitted

Reading that one user went ahead from the drush directory to give the command:
composer install

I get: -bash: composer: command not found

In short, nothing on this page works.

coolest’s picture

To install composer in OS X El Capitan try

curl -sS https://getcomposer.org/installer | sudo php

that worked for me

an then

sudo mv composer.phar /usr/local/bin/composer

Anonymous’s picture

What version of OSX do you have? Not sure if this solution will work for you, but just try to install Drush / drush dev. When I did it pulled composer automatically, you could also check into using Drupal console.

tienbienit1992’s picture

# Download latest stable release using the code below or browse to github.com/drush-ops/drush/releases.
php -r "readfile('https://s3.amazonaws.com/files.drush.org/drush.phar');" > drush
# Or use our upcoming release: php -r "readfile('https://s3.amazonaws.com/files.drush.org/drush-unstable.phar');" > drush

# Test your install.
php drush core-status

# Make `drush` executable as a command from anywhere. Destination can be anywhere on $PATH.
chmod +x drush
sudo mv drush /usr/local/bin

# Optional. Enrich the bash startup file with completion and aliases.
drush init

rajanvalecha12’s picture

1. Simply edit paths file : vim /etc/paths
2. if drush has been installed by composer add path to docroot/vendor/bin else if drush has been installed some other way add path bin directory in drush.
3. save and quit. (esc-> :wq! -> return)
4. Close and open the terminal.

Nitesh Sethia’s picture

https://blog.greggant.com/posts/2017/11/14/installing-drush-8-with-compo... article is really helpful in order to install Drush 8.

koushikuk’s picture

Install drush for drupal 8 in mac

These are the steps to install drush for drupal 8 site via composer in MAC system,

Steps:

1.Go to /Users/yourusername directory
2. Clone drush from this url : https://github.com/drush-ops/drush
3. After clone go inside this drush directory and run command composer install
Edit bash profile from command line nano ~/.bash_profile and this line
export PATH=$PATH:/Users/yourusername/drush

Now go inside your drupal 8 project and try with drush commands and now it will work.

alexmoreno’s picture

I think this documentation is a bit outdated, it should simply point here, where is always going to be more up to date: https://docs.drush.org/en/8.x/install-alternative/