How do you remove MacPorts and all the packages it has installed?

I have installed MacPorts on my Mac OS X Lion, and I would like to remove it. There should be no more trace of MacPorts?

Is there a way to do this?

2 Answers

From the manual, uninstalling MacPorts works as follows. You need to first uninstall all ports:

sudo port -fp uninstall --follow-dependents installed

If port is not found, try /opt/local/bin/port instead.

Also, to remove remainders of MacPorts, you will need to delete the following files by this single command (copy and paste line-by-line to Terminal):

sudo rm -rf /opt/local
sudo rm -rf /Applications/DarwinPorts
sudo rm -rf /Applications/MacPorts
sudo rm -rf /Library/LaunchDaemons/org.macports.*
sudo rm -rf /Library/Receipts/DarwinPorts*.pkg
sudo rm -rf /Library/Receipts/MacPorts*.pkg
sudo rm -rf /Library/StartupItems/DarwinPortsStartup
sudo rm -rf /Library/Tcl/darwinports1.0
sudo rm -rf /Library/Tcl/macports1.0
sudo rm -rf ~/.macports

Warning: Don't run a sudo command—especially a rm -rf one—unless you know what it's doing, and enter each line individually if you're unsure.

Note that MacPorts creates its own user and user group. They can be removed, too. See this answer over on Ask Different for more info.

Finally, each port installed through MacPorts may again create its own user and group, so you may have to perform a manual cleanup.

13

This guide helped me remove MacPorts:

Here's a summary (in case the link goes dead): First, uninstall MacPorts:

sudo port -f uninstall installed

Second step: remove everything that is left from MacPorts (check for MySQL and other stuff in /opt/local first):

sudo rm -rf /opt/local
sudo rm -rf /Applications/DarwinPorts
sudo rm -rf /Applications/MacPorts
sudo rm -rf /Library/LaunchDaemons/org.macports.*
sudo rm -rf /Library/Receipts/DarwinPorts*.pkg
sudo rm -rf /Library/Receipts/MacPorts*.pkg
sudo rm -rf /Library/StartupItems/DarwinPortsStartup
sudo rm -rf /Library/Tcl/darwinports1.0
sudo rm -rf /Library/Tcl/macports1.0
sudo rm -rf ~/.macports

After that you should remove the /opt/local/bin from your $PATH

5

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like