Mountain Lion php pear and pecl

11,859

Solution 1

I sorted this by installing pear again. After downloading go-pear.phar then running

sudo php -d detect_unicode=0 go-pear.phar

In the install there are options to change directories pear is using. They were already set to the correct locations for my new php such as /usr/local/php5/bin

I then had to add that path to my bash_profile for the pear command to be recognised.

export PATH=$PATH:/usr/local/php5/bin

To get pecl working again I removed pecl from /usr/bin then symlinked to the pecl in /usr/local/php5/bin

sudo ln -s /usr/local/php5/bin/pecl /usr/bin/pecl

The first package I tried to install was APC and I got the error

Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

ERROR: `phpize' failed

This was sorted by following instructions from phpize won't work on Mac OS X Lion I used the homebrew solution

UPDATE: I installed PHPUnit fine then ran phpunit --version

This gave an error of

PHP Warning:  require(/usr/lib/php/pear/PHPUnit/Autoload.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 43

Running which phpunit returned /usr/bin/phpunit

Solved by more symlinking

sudo ln -s /usr/local/php5/bin/phpunit phpunit

Solution 2

On Mavericks there's a file in /usr/lib/php called install-pear-nozlib.phar

Everything worked by just running sudo php install-pear-nozlib.phar from that directory. And then adding /usr/lib/php/pear to the include path in php.ini

Hope that helps someone

Solution 3

I have this issue with one of my users on my Mac. It works fine with the other. So I guess it could have something to do with installing pear using the other user (as that's what I did).

I have no solution to this, but you could try to install pear again and try to select to install it to system instead of local and see if that works.

Edit: I tried to do this, however pear started to work, but not pecl.

Share:
11,859
ianckc
Author by

ianckc

Updated on June 07, 2022

Comments

  • ianckc
    ianckc about 2 years

    I've upgraded to Mountain Lion and installed php5.4 which took a bit of tweaking Mountain Lion change php location

    My next issue is if I run pear -v or pecl -v these return

    Could not open input file: /usr/lib/php/pear/pearcmd.php
    
    Could not open input file: /usr/lib/php/pear/peclcmd.php
    

    Do I need to change pear and pecl to point to my new php which is installed in /usr/local/php5/bin/

    If so how do I do this and will I lose all of my previously installed extensions such as phpunit?

    Thanks