Mac OSX 10.11.6下如何卸载Pear安装的PHP CodeSniffer?
Hey there, let’s work through this frustrating PEAR install mess step by step—wonky partial installs and uninstall errors are super common when permissions get in the way, so I’ve got you covered.
Step 1: Verify PEAR’s Installed Packages & Fix Uninstall Command
First, the error you’re seeing ("tool not installed") probably means you’re using the wrong version string in your uninstall command. Let’s check what PEAR actually recognizes:
- Run this command to list all installed PEAR packages:
pear list -a - Look for any entry related to
PHP_CodeSniffer. If you see it, try uninstalling without the exact version number (PEAR often handles this better):
Note: Usesudo pear uninstall PHP_CodeSniffersudohere if you originally installed with root permissions—matching the install permissions is key.
Step 2: Manually Clean Up Residual Files (If PEAR Has No Record)
If PEAR says the package isn’t installed but you still have leftover files from the partial install, we’ll clean them manually:
- Find where PEAR stores its PHP libraries:
Navigate to this directory and delete thepear config-get php_dirCodeSnifferfolder inside thePHPdirectory (e.g.,/usr/share/php/PHP/CodeSniffer). - Find where PEAR stores executable binaries:
Delete thepear config-get bin_dirphpcsandphpcbffiles here—these are the command-line tools for PHP_CodeSniffer.
Step 3: Reinstall with Proper Permissions
Now that we’ve cleaned up, let’s reinstall correctly to avoid the partial install issue:
- If you want a system-wide install (recommended for most cases), use root permissions:
sudo pear install --alldeps PHP_CodeSniffer - If you’re installing for your local user only (no root access), use this command instead (it will install to your user’s PEAR directory):
Pro tip: After local install, make sure your user’s PEARpear install --alldeps --force PHP_CodeSnifferbin_diris added to yourPATHso you can runphpcsfrom anywhere.
Quick Check to Confirm Success
Once reinstall finishes, run:
phpcs --version
If it outputs the correct version number (3.2.3 or newer), you’re good to go!
内容的提问来源于stack exchange,提问作者permutations

