Uninstall / remove a Homebrew package including all its dependencies

后端 未结 10 1294
萌比男神i
萌比男神i 2020-12-04 04:25

I have a Homebrew formula that I wish to uninstall/remove along with all its dependencies, skipping packages whom other packages depend upon (a.k.a. Cascadi

相关标签:
10条回答
  • 2020-12-04 05:01

    Based on @jfmercer answer (corrections needed more than a comment).

    Remove package's dependencies (does not remove package):

    brew deps [FORMULA] | xargs brew remove --ignore-dependencies
    

    Remove package:

    brew remove [FORMULA]
    

    Reinstall missing libraries:

    brew missing | cut -d: -f2 | sort | uniq | xargs brew install
    

    Tested uninstalling meld after discovering MeldMerge releases.

    0 讨论(0)
  • 2020-12-04 05:03

    Using this answer requires that you create and maintain a file that contains the package names you want installed on your system. If you don't have one already, use the following command and delete the package names what you don't want to keep installed.

    brew leaves > brew_packages
    

    Then you can remove all installed, but unwanted packages and any unnecessary dependencies by running the following command

    brew_clean brew_packages
    

    brew_clean is available here: https://gist.github.com/cskeeters/10ff1295bca93808213d

    This script gets all of the packages you specified in brew_packages and all of their dependancies and compares them against the output of brew list and finally removes the unwanted packages after verifying this list with the user.

    At this point if you want to remove package a, you simply remove it from the brew_packages file then re-run brew_clean brew_packages. It will remove b, but not c.

    0 讨论(0)
  • 2020-12-04 05:07

    The goal here is to remove the given package and its dependencies without breaking another package's dependencies. I use this command:

    brew deps [FORMULA] | xargs brew remove --ignore-dependencies && brew missing | xargs brew install
    

    Note: Edited to reflect @alphadogg's helpful comment.

    0 讨论(0)
  • 2020-12-04 05:10

    You can just use a UNIX pipe for this

    brew deps [FORMULA] | xargs brew rm
    
    0 讨论(0)
提交回复
热议问题