MacPorts equivalent of apt-get autoremove

466 views, 2 replies
Tagged in: os-x mac aptitude macports 
+3
0 / 1

I recently installed gedit via macports (sudo port install gedit) which installed about 100 other unrequested packages as dependents (including things like X11, GTK, and aspell - stuff I definitely don't need in OS X).

Later I ran sudo port uninstall gedit, which worked great, but left all the other packages on my system. After attempting to run sudo port autoremove and sudo port autoclean (neither of which exist), I finally found the answer... and it's not very elegant.

I first found the command sudo port uninstall inactive which, as the documentation reads, is the solution. In my case, it's not. You might want to try it though.

I found that MacPorts refers to packages which were "installed ports that are unrequested and have no dependents" as leaves. Once you wrap your head around that, take note that many leaves may be dependent on other packages which were "unrequested." So, once you uninstall all your leaves, you'll have a whole new set of leaves. MacPorts doesn't seem to have a method to handle this recursion, so you have to iterate over your remaining leaves until there are none left.

Long story short, run this over and over again until it stops uninstalling packages:

sudo port uninstall leaves

I miss apt-get.

Flag this comment as innapropriate
Posted 11 months ago by Dolph (120)
Post a reply anonymously:
+1
0 / 1

brew is an awesome alternative to macports :D

mxcl.github.com/homebrew

Flag this comment as innapropriate
Posted 2 months ago by Anonymous (0)
+1
0 / 1

thanks, great text, you help me with the same problem!

Flag this comment as innapropriate
Posted 10 months ago by Anonymous (0)