Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

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

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.

share|improve this question
up vote 6 down vote accepted

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.

share|improve this answer
    
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 '13 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. – EOL Oct 24 '14 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”.

share|improve this answer

Your Answer

 
discard

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.