TH1981
TH1981

Reputation: 3193

using PEAR with MAC OS X

I've tried using pear to install both phpunit and phpdoc and seem to be running into a problem with my pear installation.

following the installation guide here :

  1. You can prepare your PEAR installation using the following commands: $ pear channel-discover pear.phpdoc.org

this gives me an error message: -bash: pear: command not found

I've seen mention of using $ locate bin/pear to find the installation. This gives me the following message:

WARNING: The locate database (/var/db/locate.database) does not exist.
To create the database, run the following command:

  sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist

Please be aware that the database can take some time to generate; once
the database has been created, this message will no longer appear.

Not sure what that means, but if I'm reading it correctly, it's saying that pear isn't there. I know my path to pear is /Applications/MAMP/bin/php/php5.3.6/bin/pear /Applications/MAMP/bin/php/php5.3.6/bin/pear.

I'm a little lost on what to try next. Any suggestions on what I'm doing wrong?

Upvotes: 5

Views: 2200

Answers (2)

Scott Saunders
Scott Saunders

Reputation: 30394

Try using the full path to pear:

$ /Applications/MAMP/bin/php/php5.3.6/bin/pear channel-discover pear.phpdoc.org

When you enter a unix command like that, the first part is the application that you want to run. Typing "pear" means you want to run the pear app. Your OS knows a few directories in which to look for applications. You can see what they are by entering the command:

echo $PATH

The list is separated by colons. If the application you want to run is not in one of those folders, then your OS doesn't know where to find it. It won't automatically search your entire hard drive to find an application of that name. That would be a security risk, or at the least slow and ambiguous if you have more than one app with the same name.

If you enter the entire path to your application, like I've suggested above, then your OS knows exactly where to find the application and will run it directly without searching through the directories in your PATH.

You can add new directories to your PATH and you can add an alias to an application to one of the PATH directories. Then you would be able to just type "pear" and the OS could find it. There are tutorials for adding directories to your PATH all over the internet.

The locate database needs to be created in order to use the locate command. This is a separate issue. You can build the locate database and it will look over all of your files. It will take a little while to run, but when it's done the locate command will work. However, since you already know where your pear app is, locate won't give you any new information.

Upvotes: 3

dm03514
dm03514

Reputation: 55932

Create your locate database using the command given. You can think of this in terms of the way spotlight has to "load" or index everything when you first install osx. 'can take some time' usually means 'will take some time'

If you know your pear path you can execute it directly:

/Applications/MAMP/bin/php/php5.3.6/bin/pear channel-discover pear.phpdoc.org

or add an alias to it manually in your bash profile directory http://blog.elucidcode.com/2011/03/terminal-aliases-in-os-x/

or make a link to it in /usr/bin.

For an overview. It seems pear is installed fine. Just when you type in 'pear' into the console osx doesn't recognize that as being a command, Its like a shortcut on your desktop that doesn't point to anywhere. What needs to be done (using one of the methods above) is to point the "desktop shortcut" (the pear command) to the actually pear binary.

Upvotes: 5

Related Questions