Which command should I run to

  • delete all old port versions
  • delete downloaded files
  • temp files created during build
  • all other stuff which I don't need when I am sure that updated version works fine

I got a suggestion to use

port clean --all all

but it tries to clean ports I don't have, though I tried

port clean --all installed

but it did not delete old inactive versions, then

port -u uninstall

but it got stuck saying that py25-nose (which is active) depends on py25-setuptools (which is inactive).

3 Answers 3


The suggestions you received cover what you're after:

sudo port -f clean --all all
sudo port -f uninstall inactive

If you can't wait for the clean one to run in the background, there are a few commands you can run manually and faster.

Remove leftover build files (this is done automatically by default):

sudo rm -rf /opt/local/var/macports/build/*

Remove download files:

sudo rm -rf /opt/local/var/macports/distfiles/*

Remove archives (these aren't created by default):

sudo rm -rf /opt/local/var/macports/packages/*
  • What about deleting inactive ports taking into account problem with py25-nose which I described?
    – tig
    Jul 20, 2010 at 22:04
  • 1
    port -f uninstall inactive
    – Jeremy L
    Jul 21, 2010 at 10:42
  • Updated to add it since you're after two separate things.
    – Jeremy L
    Jul 22, 2010 at 0:33
  • Thanks! When I did a macports upgrade it started downloading about 15 GiB of tex stuff I didn't want. I was panicking about how to remove the crap. Thank you!
    – Wyatt Ward
    Jan 29, 2014 at 5:09
  • 3
    I have 1.8 GiB of .tbz2 archives in /opt/local/var/macports/software surely they can go... according to apple.stackexchange.com/questions/64074/… they can be deleted Oct 15, 2014 at 13:05
port uninstall inactive

is the way to go.

  • Still complains about py25-nose depending on py25-setuptools
    – tig
    Jul 20, 2010 at 21:50
  • 2
    "port -f uninstall inactive" will force this behavior to be overridden.
    – user43383
    Jul 21, 2010 at 6:55
  • 2
    @tig This is a bug with the old registry format and is fixed when using the sqlite registry introduced with 1.9. The announce for 1.9.0 has instructions how to switch: lists.macosforge.org/pipermail/macports-announce/2010-June/…
    – raimue
    Sep 5, 2010 at 23:54
  • @Raim: Thank you very much! leaves pseudo name will be of a great help for me!
    – tig
    Sep 6, 2010 at 21:20

I just wanted to add my experiences with the above in case it helps anyone else: When I ran

port clean --all all

it ran for several minutes, and this made me concerned, so I interrupted the process.

I too, wanted to "clean up" after multiple installs of Macports on Yosemite. I had installed first via Terminal, and then did

rm -rf MacPorts-2.3.3 which I realized does not clean up, because I saw the command port stopped working.

My solution: I installed again with the pkg installer, which doesn't leave any directories behind.

  • // , Thanks for the answer! Does the pkg installer work with macports, or should I uninstall macports before using pkg? Nov 30, 2015 at 17:33
  • I followed Macports' recommendation: the pkg or dmg [installer][1] depending on your Mac OS version. I did not have to manually remove, or uninstall any old versions, directories, etc. when using the installer. For example, I recently updated from Yosemite to El Capitan, and Macports had to be re-installed. You could later perform maintanance with some [common tasks][2] and commands like sudo port selfupdate and sudo port upgrade outdated Hth! [1]: macports.org/install.php [2]: guide.macports.org/chunked/using.common-tasks.html Dec 1, 2015 at 19:31

You must log in to answer this question.

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