7

I've installed drush in /usr/local/lib/drush/drush and composer in /usr/local/bin/composer.

When I try to run drush /usr/local/lib/drush/drush I get the following:

/usr/local/lib/drush/drush: line 129: /Applications/MAMP/bin/php/php5.2.17/bin: is a directory /usr/local/lib/drush/drush: line 129: exec: /Applications/MAMP/bin/php/php5.2.17/bin: cannot execute: Undefined error: 0 –

OR the following:

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

What am I doing wrong? I'd like to install drush to use with MAMP if anyone has any suggestions. I've done through the readme and nothing seems to be working.

1
  • 1
    Have you set the environment variable DRUSH_PHP? It looks like Drush is trying to exec the 'bin' directory that PHP is in, rather than the php executable itself. Point directly at php, as shown in tenken's answer. Mar 6, 2014 at 22:21

3 Answers 3

8

Drush switched to requiring composer. The documentation provides details on how to install both composer and drush, but it boils down to:

  • Install composer globally:

    curl -sS https://getcomposer.org/installer | php
    mv composer.phar /usr/local/bin/composer
    
  • Install drush globally (for your user), you can specify the version:

    composer global require drush/drush:6.*
    
  • Add the composer path to your path (in your .bashrc or .zshrc or other):

    export PATH="$HOME/.composer/vendor/bin:$PATH"
    
2
  • when I run mv composer.phar /usr/local/bin/composer I get a denied permission message. It seems like I can't access this path.
    – chefnelone
    May 13, 2015 at 15:49
  • You'll have to run that command as the superuser. If your server uses sudo, prefix that command with it.
    – T0xicCode
    May 13, 2015 at 15:54
3

These were the steps I used to install drush globally using composer in Linux (not in ~/.composer/vendor/bin logged in as root which makes absolutely no sense):

  1. Login as root
  2. Install composer if necessary. See. http://getcomposer.org/doc/00-intro.md#system-requirements.
  3. composer global require drush/drush:6.* or composer global require drush/drush:dev-master
  4. cd ~/.composer
  5. composer config --global bin-dir /usr/local/bin
  6. composer config --global vendor-dir /usr/local/share
  7. composer install
  8. cp -r vendor/ /usr/local/share/drush/drush/
  9. cd /usr/local/share/drush/drush
  10. composer install

Now any user with /usr/local/bin in their path can run drush.

Security precaution: You might want to chown and chmod /usr/local/bin/drush so only authorized users in a certain group can execute drush.

Notes: Lines 5 and 6 create the file ~/.composer/config.json. Line 10 is needed to delete (yes, delete) the /usr/local/share/drush/drush/vendor/drush folder which is unnecessary.

2
  • You guided me there. In my case it was simply to go to '/usr/share/drush7' and run 'composer install'. Easy.
    – Meetai.com
    Dec 29, 2014 at 4:03
  • I am stuck on Line 8, it gives me the error that cp: /usr/local/share/drush/drush/drush: Not a directory - For all the further directories
    – pal4life
    Mar 23, 2015 at 15:38
2

Have you googled for like "OSX + drush + mamp" ... http://kerasai.com/blog/2013/07/30/easy-way-make-drush-work-mamp

The main hiccup with drush on MAMP is that drush doesn't use the PHP packaged with MAMP and commonly the PHP shipped with OSX is not configured to meet Drupal's requirements. It's possible to reconfigure the PHP that ships with OSX to meet Drupal's requirements, but wouldn't the smart thing to do be to use MAMP's PHP? You can do this by adding the following line to ~/.profile, adjust as needed.

alias drush='DRUSH_PHP=/Applications/MAMP/bin/php/php5.4.10/bin/php /usr/local/drush/drush'
4
  • Thanks! Yes I did google and went through a lot of trial and error... After adding to .bash_profile I'm getting the following when I try to execute drush: -bash: /usr/local/drush/drush: No such file or directory
    – radishred
    Mar 6, 2014 at 23:00
  • @radishred From the looks of the question your drush install is at /usr/local/lib/drush/drush, so just replace as necessary
    – Clive
    Mar 7, 2014 at 1:57
  • Thanks Clive, still not working so I started over using homebrew and for the most part was pretty easy.
    – radishred
    Mar 7, 2014 at 16:44
  • No .profile but default on Mountain lion for me
    – pal4life
    Mar 16, 2015 at 21:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.