You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac OSX 10.11.6下如何卸载Pear安装的PHP CodeSniffer?

Fixing PHP_CodeSniffer Uninstall/Reinstall Issues with PEAR

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):
    sudo pear uninstall PHP_CodeSniffer
    
    Note: Use sudo here 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:

  1. Find where PEAR stores its PHP libraries:
    pear config-get php_dir
    
    Navigate to this directory and delete the CodeSniffer folder inside the PHP directory (e.g., /usr/share/php/PHP/CodeSniffer).
  2. Find where PEAR stores executable binaries:
    pear config-get bin_dir
    
    Delete the phpcs and phpcbf files 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):
    pear install --alldeps --force PHP_CodeSniffer
    
    Pro tip: After local install, make sure your user’s PEAR bin_dir is added to your PATH so you can run phpcs from 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 03:43:53