DEV Community

Derek Hopper
Derek Hopper

Posted on • Updated on

What tips do you have for homebrew users?

This morning, I recovered 110 GB of disk space thanks to one command.

I'm a heavy homebrew user. I install packages all the time. On top of that, I brew update and brew upgrade quite often. I like to stay up to date.

Over the years, I continued to install packages, update, and upgrade them. All the while I was ignoring one important command.

My Story

This morning, I was greeted with this alert. Hmmmm... I thought. What could this be?

The Low Disk Space Alert

My documents folder had a few gigabytes of data, but that wasn't filling up my entire disk. That's when I started exploring homebrew packages. I realized I had been keeping many, many old homebrew packages around for no reason.

The Command

That's when I ran the command brew cleanup. Oh boy, I was in for a surprise. My terminal started spitting out line after line of this:

brew cleanup log

That's a lot of disk space!

After that completed (which took about 15 minutes), I suddenly had 120 GB of free space to work with. And that got me thinking, what else do I not know about homebrew? Do you have any tips for us homebrew users out there?

Discussion (3)

Collapse
clpsplug profile image
C. Plug

There's an argument switch to have homebrew do clean-up every time it upgrades!

brew upgrade --cleanup
==> Upgrading tbb
==> Downloading https://homebrew.bintray.com/bottles/tbb-2019_U2.mojave.bottle.t
######################################################################## 100.0%
==> Pouring tbb-2019_U2.mojave.bottle.tar.gz
🍺  /usr/local/Cellar/tbb/2019_U2: 134 files, 2.7MB
Removing: /usr/local/Cellar/tbb/2019_U1... (134 files, 2.7MB)
Removing: /Users/me XD/Library/Caches/Homebrew/tbb--2019_U1.mojave.bottle.tar.gz... (660.2KB)
Collapse
rhymes profile image
rhymes

Ah ah the magic cleanup!

I created an alias so I won't forget:

> alias brew-upgrade
brew-upgrade='brew update && brew upgrade && brew cask upgrade && brew cleanup'
Collapse
aikedejongste profile image
Aike de Jongste

==> This operation has freed approximately 417.6MB of disk space.

My tip would be to use a Brewfile: robots.thoughtbot.com/brewfile-a-g...