Upgrading PEAR on MAMP (including fix for PEAR 1.9.1 problem)
OK.. This task turned out to be much more complicated than it needed to be. After following information in the following threads I had no luck getting PEAR 1.9.1 working with MAMP. You may be asking, why upgrade? PHPUnit requires PEAR 1.9.1 or higher.
- http://forum.mamp.info/viewtopic.php?f=6&t=9355
- http://serverfault.com/questions/184741/upgrading-pear-from-1-9-0-to-1-9-1-fails
I finally found a solution at: http://qussaynajjar.com/2011/02/06/installing-phpunit-with-mamp/ which basically just installs a fresh copy of PEAR inside of MAMP. (Note: I did not have to do the editing of files or changing of permissions to get things working for pear or phpunit as detailed in the qussaynajjar.com post)
$ cd /Applications/MAMP/bin/php5.3/
$ curl -O http://pear.php.net/go-pear
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 87667 100 87667 0 0 69291 0 0:00:01 0:00:01 --:--:-- 83254
$ php go-pear.php
Welcome to go-pear!
Go-pear will install the 'pear' command and all the files needed by
it. This command is your tool for PEAR installation and maintenance.
Go-pear also lets you download and install the following optional PEAR
packages: PEAR_Frontend_Web-beta, PEAR_Frontend_Gtk2, MDB2.
If you wish to abort, press Control-C now, or press Enter to continue:
HTTP proxy (http://user:password@proxy.myhost.com:port), or Enter for none::
Below is a suggested file layout for your new PEAR installation. To
change individual locations, type the number in front of the
directory. Type 'all' to change all of them or simply press Enter to
accept these locations.
1. Installation prefix ($prefix) : /Applications/MAMP/bin/php5.3
2. Temporary files directory : $prefix/temp
3. Binaries directory : $prefix/bin
4. PHP code directory ($php_dir) : $prefix/PEAR
5. Documentation base directory : $php_dir/docs
6. Data base directory : $php_dir/data
7. Tests base directory : $php_dir/tests
1-7, 'all' or Enter to continue:
The following PEAR packages are bundled with PHP: PEAR_Frontend_Web-beta,
PEAR_Frontend_Gtk2, MDB2.
Would you like to install these as well? [Y/n] : n
Loading zlib: ok
Bootstrapping Installer...................
Bootstrapping PEAR.php............(remote) ok
Bootstrapping Archive/Tar.php............(remote) ok
Bootstrapping Console/Getopt.php............(remote) ok
Extracting installer..................
Downloading package: PEAR.............ok
Downloading package: Structures_Graph....ok
Preparing installer..................
Updating channel "doc.php.net"
Channel "doc.php.net" is up to date
Updating channel "pear.php.net"
Channel "pear.php.net" is up to date
Updating channel "pecl.php.net"
Channel "pecl.php.net" is up to date
Installing selected packages..................
Downloading and installing package: PEAR.............warning: pear/PEAR requires package "pear/Archive_Tar" (recommended version 1.3.7)
warning: pear/PEAR requires package "pear/Structures_Graph" (recommended version 1.0.3)
warning: pear/PEAR requires package "pear/Console_Getopt" (recommended version 1.2.3)
warning: pear/PEAR requires package "pear/XML_Util" (recommended version 1.2.1)
downloading PEAR-1.9.1.tgz ...
Starting to download PEAR-1.9.1.tgz (293,587 bytes)
.............................................................done: 293,587 bytes
install ok: channel://pear.php.net/PEAR-1.9.1
PEAR: Optional feature webinstaller available (PEAR's web-based installer)
PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer)
PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer)
PEAR: To install optional features use "pear install pear/PEAR#featurename"
Installing bootstrap package: Structures_Graph.......install ok: channel://pear.php.net/Structures_Graph-1.0.4
Downloading and installing package: Archive_Tar-stable.......downloading Archive_Tar-1.3.7.tgz ...
Starting to download Archive_Tar-1.3.7.tgz (17,610 bytes)
...done: 17,610 bytes
install ok: channel://pear.php.net/Archive_Tar-1.3.7
Downloading and installing package: Console_Getopt-stable.......downloading Console_Getopt-1.3.0.tgz ...
Starting to download Console_Getopt-1.3.0.tgz (4,408 bytes)
...done: 4,408 bytes
install ok: channel://pear.php.net/Console_Getopt-1.3.0
******************************************************************************
WARNING! The include_path defined in the currently used php.ini does not
contain the PEAR PHP directory you just specified:
If the specified directory is also not in the include_path used by
your scripts, you will have problems getting any PEAR packages working.
Would you like to alter php.ini ? [Y/n] : y
php.ini include_path updated.
Current include path : .:/Applications/MAMP/bin/php5.3/lib/php
Configured directory : /Applications/MAMP/bin/php5.3/PEAR
Currently used php.ini (guess) : /Applications/MAMP/conf/php5.3/php.ini
Press Enter to continue:
** WARNING! Old version found at /usr/bin/pear, please remove it or be sure to use the new /Applications/MAMP/bin/php5.3/bin/pear command
The 'pear' command is now at your service at /Applications/MAMP/bin/php5.3/bin/pear
$ pear -V
PEAR Version: 1.9.1
PHP Version: 5.3.2
Zend Engine Version: 2.3.0
Running on: Darwin jyoung-macmini 10.6.0 Darwin Kernel Version 10.6.0: Wed Nov 10 18:13:17 PST 2010; root:xnu-1504.9.26~3/RELEASE_I386 i386
$ pear list
Installed packages, channel pear.php.net:
=========================================
Package Version State
Archive_Tar 1.3.7 stable
Console_Getopt 1.3.0 stable
PEAR 1.9.1 stable
Structures_Graph 1.0.4 stable
For ease of use, make sure you set your $PATH to the following in your .bash_profile
export PATH=/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5.3/bin:$PATH
You can verify that you are using the right pear by doing:
$ which pear /Applications/MAMP/bin/php5.3/bin/pear


Thank you so much!
I’ve been looking for hours on the web and followed god-knows how many step-by-steps on stackoverflow etc. this one finally worked.
One note tho for future crawlers, it appears in some cases (atleast mine) it ended up installing itself as “peardev” rather than “pear”.
Although one may be able to rename it, I added the following to my $HOME/.profile (or add it to /.etc./bashrc)
alias pear=’peardev’
In order for it to work under sudo, it has to be deeper down.
I’ve removed the alias from .profile. Instead in your terminal do
$ cd /Applications/MAMP/bin/php5.3/bin/
$ cd ln -s peardev pear
Which will create a symbolic alias in the directory that works everywhere.