Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 20 down vote accepted

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 it to Terminal):

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

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 (e.g. sudo rm -rf /Applications/DarwinPorts, then sudo rm -rf /Library/LaunchDaemons/org.macports.*).

share|improve this answer
I did this and: $ brew doctor gives: Warning: Setting DYLD_LIBRARY_PATH can break dynamic linking. You should probably unset it. – Devin G Rhode Nov 9 '12 at 8:22
Interesting. Did you ever set it? Like, in the bash profile, bashrc, etc? – slhck Nov 9 '12 at 8:45
No, BRAND NEW OS install too, this is something macports did, I think. However, echo $DYLD_LIBRARY_PATH spits out paths to a mysql binary – Devin G Rhode Nov 9 '12 at 16:57
It could have also been some rake or rails stuff, but I highly doubt it. – Devin G Rhode Nov 9 '12 at 16:57
@Chet Unless you put something there, no. /opt/ does not even exist in a default OS X installation, so you can safely remove it. – slhck Apr 15 '14 at 7:24

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

share|improve this answer
Can you summarize what is at the link in your answer in case the link goes dead? – jonsca Aug 13 '13 at 7:15
Everywhere I look, there's "if you have a working port command, then use sudo port blah". What if, like in my case, port isn't working? – frumbert Dec 2 '13 at 21:27
Separate the sudo rm -rf long command into serveral short command works really good for me. – Kevin Tong Sep 3 '14 at 16:15
@frumbert I know it has been 2 years since your comment date. However for further reference, let me tell my story. Macports was running on my OSX Yosemite system which I upgraded to El Capitan. Then, I decided to remove macports completely. For this, I reinstalled macports for El Capitan, then I followed what is told in the above answer. Hope this can help someone ;-) – Lashae Dec 30 '15 at 16:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.