Clean MacPorts

Low on disk space? You might need to check your macports space usage.  I’m always tight on space since I primarily use SSDs in my machines. Here are some tips I use to help clean macports.

The following are some shell commands you can use to help reclaim disk space from macports. I’ve gathered these from around the web, and tested that each one is safe to use (on my machines at least!). Using all of them combined can save gigabytes of space!

Run these commands in a terminal to help clean up your macports installation:

#Remove misc leftover data:
sudo port clean --all installed
sudo port -f uninstall inactive

#Remove leftover build files:
sudo rm -rf /opt/local/var/macports/build/*

#Remove download files:
sudo rm -rf /opt/local/var/macports/distfiles/*

#Remove archives:
sudo rm -rf /opt/local/var/macports/packages/*

#Remove dependencies of uninstalled ports:
sudo port -f uninstall leaves

Alternatively, download a handy bash script of the above HERE

Example results of running  clean-macports.sh

Screen Shot 2015-05-22 at 9.01.43 PM-G
Over 3GB space savings on my hackintosh!
Screen Shot 2015-06-08 at 6.32.30 PM-G
Over 4GB savings on my macbook!

Hope this helps! Please leave your own tips for managing and save disk space usage of macports.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.