Uninstall / remove a Homebrew package including all its dependencies

后端 未结 10 1312
萌比男神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 04:44

    EDIT:

    It looks like the issue is now solved using an external command called brew rmdeps or brew rmtree.

    To install and use, issue the following commands:

    $ brew tap beeftornado/rmtree
    $ brew rmtree 
    

    See the above link for more information and discussion.


    Original answer:

    It appears that currently, there's no easy way to accomplish this.

    However, I filed an issue on Homebrew's GitHub page, and somebody suggested a temporary solution until they add an exclusive command to solve this.

    There's an external command called brew leaves which prints all packages that are not dependencies of other packages.

    If you do a logical and on the output of brew leaves and brew deps , you might just get a list of the orphaned dependency packages, which you can uninstall manually afterwards. Combine this with xargs and you'll get what you need, I guess (untested, don't count on this).


    EDIT: Somebody just suggested a very similar solution, using join instead of xargs:

    brew rm FORMULA
    brew rm $(join <(brew leaves) <(brew deps FORMULA))
    

    See the comment on the issue mentioned above for more info.

提交回复
热议问题