42

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?

1

2 Answers 2

39

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
  • I did this and: $ brew doctor gives: Warning: Setting DYLD_LIBRARY_PATH can break dynamic linking. You should probably unset it. Nov 9, 2012 at 8:22
  • Interesting. Did you ever set it? Like, in the bash profile, bashrc, etc?
    – slhck
    Nov 9, 2012 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 Nov 9, 2012 at 16:57
  • 1
    @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, 2014 at 7:24
  • 1
    Note that macports also creates its own user and group (see trac.macports.org/ticket/31013 ) and removing them is described over in apple.stackexchange.com/questions/317576/… . Also note that installed ports may themselves may create new users and groups...
    – Anon
    Sep 27, 2018 at 8:53
7

This guide helped me remove MacPorts: http://bitboxer.de/2010/06/03/moving-from-macports-to-homebrew/

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
  • 3
    Can you summarize what is at the link in your answer in case the link goes dead?
    – jonsca
    Aug 13, 2013 at 7:15
  • 2
    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, 2013 at 21:27
  • Does this help: stackoverflow.com/questions/9694395/sudo-port-command-not-found ?
    – Quentin
    Dec 2, 2013 at 21:59
  • Separate the sudo rm -rf long command into serveral short command works really good for me.
    – Kevin Tong
    Sep 3, 2014 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, 2015 at 16:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .