Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ChristopherA/3448ed55657766eeaab809dc1416849f to your computer and use it in GitHub Desktop.
Save ChristopherA/3448ed55657766eeaab809dc1416849f to your computer and use it in GitHub Desktop.
Uninstall brew package and dependencies

Uninstall brew package and dependencies

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
@Amar1729
Copy link

@mrgloom , brew deps will show what kegs a formula depends on; the uninstall error message is telling you what other formula depend on the one you're trying to uninstall (or "reverse-dependencies"). you can show these with:

$ brew uses --installed [FORMULA]

@brifordwylie
Copy link

Hey, so depending on the FORMULA that you're uninstalling this command can be quite dangerous

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

If the formula has a lot of dependencies that are required for other packages, stuff get broken :(

@Amar1729
Copy link

Amar1729 commented Apr 30, 2020

This problem is more robustly solved by something like brew rmtree

@ianribas
Copy link

Just a small suggestion of an improvement on that last line:

brew missing | cut -d: -f2 | tr ' ' "\n" | sort | uniq | xargs brew install

So that duplicates are really removed.

@seguri
Copy link

seguri commented Dec 14, 2020

@squm
Copy link

squm commented May 16, 2021

brew autoremove

@soplwang
Copy link

brew autoremove

It works!

@pmsaue0
Copy link

pmsaue0 commented Jan 15, 2022

brew uninstall [formula] ; brew autoremove

FTW

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment