Development machines can build up such a lot of cruft. Old versions, oudated programs and unused caches litter the hard drive. It’s good to take time once in a while to clean all of this up and free up some space.
Here are some tips for commands you can run or actions you can take to clean up your machine. If you have a tip that I’m missing here, please share it with me on Twitter.
If you’re using Homebrew to manage packages on macOS you can run
brew cleanup to remove old versions of packages and old downloads from the cache.
$ brew cleanup Removing: ... ... ==> This operation has freed approximately 6.9GB of disk space.
alias bu="brew update && brew upgrade && brew cleanup"
Then run the commands with:
Everything should be up to date and leave no mess behind!
Once all the caches have been tidied up, take a moment to make sure Homebrew itself is running smoothly. Run the following command for a list of actions you can take to tidy up your install.
A few gigabytes of packages is a pretty good, but can we do better? If you’re using Docker you can clean things up with:
$ docker volume prune ... Total reclaimed space: 40.77GB
I am not a big Docker user myself, this was a tip from Jack Wearden.
I install multiple versions of Ruby using rbenv and ruby-build. I just checked the versions I have installed and I found 12 Rubies that are beyond end of life. Since they also have their gems installed alongside them, clearing them out saved me tens to hundreds of megabytes per Ruby version.
You can check the versions you have installed with:
You can then uninstall an unwanted version of Ruby with:
rbenv uninstall 2.1.0
I also use nvm to manage multiple versions of Node.js. The drill is the same here as with Ruby. Find the old Node versions that you have hanging around with:
Then uninstall with:
nvm uninstall v6.9.2
That should clear up a bunch of space on your machine, it sure did on mine. Now you have more room for more installs, more containers and more versions of more languages!
I’d love to collect any other tips that you might have to keep a development machine running smooth and lean. Let me know how you spring clean your development machine on Twitter at @philnash.
Dust icon by Smalllike from the Noun Project