How To Install Drush on MAC OSX running MAMP

Tagged:  

Here are my notes on getting drush installed on my dev machine.
My command line notes are in (parenthesis).
Basically I have updated the directions from http://mblog.lib.umich.edu/DataDiscussions/archives/2010/09/how_to_install.html to work with my MAC OSX running Drupal on MAMP. I changed the links to needed files (Console_Table-1.1.3.tgz) and changed commands to work with MAC OSX (i.e. curl instead of wget).
I hope this helps everyone. Ive spent a couple hours trying to get Drush working on my MAMP MAC OSX system and was finally able to get it to work by following the directions below.
 
1) Get installation directions (inside README.txt) by going to the Drush FAQ. Read instructions.
http://drupalcode.org/project/drush.git/blob/HEAD:/README.txt
 
2) Download the latest version of Drush from the project page. http://drupal.org/project/drush
$ sudo curl -O http://ftp.drupal.org/files/projects/drush-7.x-5.7.tar.gz (use latest version - filename will change)
 
3) Unpack the tar.gz into your desired directory. I put it in /opt (not sure if that is recommended practice though.)
$ sudo mv drush-7.x-5.7.tar.gz /opt/ (use latest version - filename will change)
$ cd /opt/
$ sudo tar -xzf drush-7.x-5.7.tar.gz (use latest version - filename will change)
$ sudo rm drush-7.x-5.7.tar.gz (to keep opt clean - use latest version - filename will change)
 
4) Make the drush command executable
$ sudo chmod u+x /opt/drush/drush
$ sudo ln -s /opt/drush/drush /bin/drush
 
5) Check if drush is working
$ drush help
 
I got this error at first:
exec: 53: php: not found
The fix, for me, was buried in this tutorial:
If you get an "exec: 53: php: not found" error after running the last line ("sudo drush dl drush_make") you might have to install the PHP command line interface, with
 
$ sudo apt-get install php5-cli
From: http://groups.drupal.org/node/70268
 
6) Check if drush is working, again:
$ drush help
 
New error (but not so helpful error because the link to Console_Table is not working!)
 
PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/mcrypt.ini on line 1 in Unknown on line 0
Drush needs a copy of the PEAR Console_Table library in order to [error]
function, and the attempt to download this file automatically failed
because you do not have permission to write files in
/opt/drush/includes. To continue you will need to download the 1.1.3
package from http://pear.php.net/package/Console_Table, extract it,
and copy the Table.php file into Drush's directory as
/opt/drush/includes/table.inc.
Drush could not execute.
 
7) Do what the Error Message tells you to do:
- Download the PEAR Console_Table library (from the working location)
$ sudo curl -O http://pkgs.fedoraproject.org/repo/pkgs/php-pear-Console-Table/Console_Table-1.1.3.tgz/34b5f34db1ab0c4daedf2862958af257/Console_Table-1.1.3.tgz
$ sudo tar -xzf Console_Table-1.1.3.tgz
$ sudo cp Console_Table-1.1.3/Table.php /opt/drush/includes/table.inc (keeping this command)
$ sudo mv Console_Table-1.1.3 /Applications/MAMP/bin/php/php5.3.6/lib/php/drush/lib
$ sudo rm Console_Table-1.1.3.tgz (clean up folder)
8) Check if drush is working, yet again:
$ drush help
 
9) Success, next step is to learn drush commands.
 
10) When I tried issuing the command drush cache-clear from my drupal folder I received this error:
 
Drush command terminated abnormally due to an unrecoverable error.   [error]
Error: Allowed memory size of 33554432 bytes exhausted (tried to
allocate 32768 bytes) in /Users/bkenyon/Google
Drive/KenyonWS/Dropbox/html/d7/includes/common.inc, line 7166
Your memory limit is set to 32M; drush needs as much memory to run as[error]
Drupal.  Please check your configuration settings in
/Applications/MAMP/bin/php/php5.3.6/conf/php.ini or in your drush.ini
file; see examples/example.drush.ini for details.
 
I did what the directions told me to do and increased the memory to 64M by going to the configuration file /Applications/MAMP/bin/php/php5.3.6/conf/php.ini and changed the memory amount.