The MacPorts directory /opt/local/var/macports/software is really full of "stuff":

Can all the .tbz2 files be deleted?

I am running out of space on the SSD.

3 Answers 3


Yes all the files in that folder located with in ${prefix}/var/macports/software/ can be deleted. Those are the installer packages for programs that you installed using MacPorts. MacPorts will re-download those as necessary when running the install or presumably the upgrade command too for a given program ,etc.

The descripton of the purpose of the directory ... is noted in MacPorts Guide under Binary Archives.

3.4.1. Binary Archives

Binary archives can only be used on a target system running MacPorts. Binary archives allow MacPorts utilities to begin installation after the destroot phase and install and activate a port on the target system. Binary archives are created whenever a port is installed, and can also be downloaded from a server.


Binary archive files are placed in ${prefix}/var/macports/software/. The archive file type is set in the macports.conf file. The default format is .tbz2; other options are: tar, tbz, tbz2, tgz, tlz, txz, xar, zip, cpgz, cpio.

  • 1
    Is there a means to have this done automatically? I mean, some configuration so that sudo port upgrade outdated always cleans these files when done. TIA!
    – akim
    Oct 7, 2013 at 9:14
  • It is not clear to me from the official description that MacPort will not need these binary archives at some point. However, from the discussion at trac.macports.org/wiki/howto/ShareArchives2, it looks like these binary archives can be used when you have multiple computers: you do the compilation on one computer, and then you can share the result. If this is their only purpose, then deleting them is obviously fine. Oct 24, 2014 at 12:13

Before going about deleting files manually in the “software” directory, I would suggest running the command sudo port uninstall inactive. The command will remove all the inactive archives from “software”. If you delete files manually from “software” after that, you’ll be deleting active archives. I’m not sure there’s much harm in doing that, but I’m not sure it’s harmless either.

The MacPorts “install” command goes through several phases, the final two being the “install” phase and the “activate” phase:

install: Archive a port's destrooted files into ${prefix}/var/macports/software. […]

activate: Extract the port's files from the archive in ${prefix}/var/macports/software to their final installed locations, usually inside ${prefix}.

The “software” directory can contain archives that are not active, in particular old versions of ports that you have upgraded, because the “upgrade” command does not remove old versions by default:

upgrade does not uninstall the old version of a port. Instead, it deactivates it […] This allows you to go back to the older version if there happens to be a problem with the updated one. […] If you do not want to keep the old versions around while upgrading, you can pass -u when upgrading: […] However, we instead recommend keeping the older versions around for a while and running sudo port uninstall inactive once in a while.

The MacPorts FAQ only suggests using the “uninstall” command to get rid of unwanted files in “software”:

What are the folders in ${prefix}/var/macports/ for and why do they take up so much space?
software: Contains the compressed archives of installed software. If a port is activated its files are extracted to the ${prefix} folders from the compressed files here. port uninstall <port> <version>+<variant> would remove it from here, but then this port can not be used anymore.

There doesn’t seem to be a switch for the “uninstall” command to uninstall an archive from “software” without also deactivating it first if it’s the active archive. So I assume it’s not a good idea either to manually remove active archives from “software”.


As Rinzwind said, you can uninstall (ie delete) any inactive versions of ports left behind by upgrades:

port uninstall inactive

If you install a port, all its dependencies are installed. If you uninstall a port, its dependencies are not uninstalled. You can uninstall them using the cutleaves utility:

port install port_cutleaves

This only removes one layer of obsolete dependencies at a time; to remove them all, i use a hacky pipeline:

while ! yes u | port_cutleaves -b | grep 'There are no new leaves to process.'; do : ; done

You can remove all the build-related files (work files, distribution files, temporary archives and logs) for uninstalled ports:

port clean --all uninstalled

To remove just the work files for installed ports:

port clean installed

The cleaning seems to touch every single port in the tree. I don't know what's going on there.

You must log in to answer this question.

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