Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does brew cleanup or brew cleanup -n don't show any output? [closed]

Tags:

macos

homebrew

I would love to clean my device of any homebrew update or version copies and then I figured that the command used for that would be

brew cleanup

and if I wanted to check how much of storage it would clear, the command would be

brew cleanup -n
brew cleanup --dry-run

None of them seem to work for me, and I want to clear my computer of any extra useless copies of Homebrew.

Also, would it be possible that it is actually happening but it is not showing me any output?

Here is the output:

temp@Apples-MacBook-Pro ~ % brew cleanup -n
temp@Apples-MacBook-Pro ~ % brew cleanup   
temp@Apples-MacBook-Pro ~ % 

All I need is some output showing how much space can be cleared / is cleared when I run the command.

Would it be possible that since I installed home-brew just yesterday, there is nothing to delete and hence this output?

like image 672
Rajat Shenoi Avatar asked Dec 30 '20 06:12

Rajat Shenoi


1 Answers

It's probably because there is nothing to clean up (especially if you've only had Homebrew for 1 day).

I am not sure what you mean by "I want to clear my computer of any extra useless copies of home-brew." because that's not what brew cleanup is for. It's for deleting old and unused files downloaded by Homebrew during brew install. It's not for clearing old versions of Homebrew (that is automatically done when you do brew update).

~$ brew cleanup --help
Usage: brew cleanup [options] [formula|cask]

Remove stale lock files and outdated downloads for all formulae and casks, and
remove old versions of installed formulae. If arguments are specified, only do
this for the given formulae and casks. Removes all downloads more than 120 days
old. This can be adjusted with HOMEBREW_CLEANUP_MAX_AGE_DAYS.

      --prune                      Remove all cache files older than specified
                                   days.
  -n, --dry-run                    Show what would be removed, but do not
                                   actually remove anything.
  -s                               Scrub the cache, including downloads for
                                   even the latest versions. Note downloads
                                   for any installed formulae or casks will
                                   still not be deleted. If you want to delete
                                   those too: rm -rf "$(brew --cache)"
      --prune-prefix               Only prune the symlinks and directories
                                   from the prefix and remove no other files.

Notice the part of "Removes all downloads more than 120 days old.". If you haven't installed that many things with Homebrew and/or you have not been using it for a long time, then it's expected that there is nothing to clean up. Also, even with the -s option, Homebrew does not delete files for "any installed formulae or casks".

Try installing and uninstall something, then do brew cleanup:

~$ brew install grep amazon-ecs-cli iterm2
...

~$ brew cleanup -s -n
~$
~$ brew uninstall grep amazon-ecs-cli iterm2
Uninstalling /usr/local/Cellar/grep/3.6... (21 files, 964.6KB)
Uninstalling /usr/local/Cellar/amazon-ecs-cli/1.21.0... (7 files, 46.2MB)
==> Uninstalling Cask iterm2
==> Backing App 'iTerm.app' up to '/usr/local/Caskroom/iterm2/3.4.3/iTerm.app'.
==> Removing App '/Applications/iTerm.app'.
==> Purging files for version 3.4.3 of Cask iterm2

~$ brew cleanup -s -n
Would remove: /Users/me/Library/Caches/Homebrew/amazon-ecs-cli--1.21.0.catalina.bottle.tar.gz (14.8MB)
Would remove: /Users/me/Library/Caches/Homebrew/grep--3.6.catalina.bottle.tar.gz (330.8KB)
Would remove: /Users/me/Library/Caches/Homebrew/Cask/iterm2--3.4.3.zip (21.3MB)
==> This operation would free approximately 36.4MB of disk space.

Notice that doing brew cleanup while those formulae are installed, it does not show any output. Only when they are uninstalled does it become something to clean.

Or try passing in the --prune=1 option (remove all cache files older than 1 day) and the -s option (scrub the cache, even for latest versions). On my system where I've had Homebrew for years:

~$ brew cleanup --prune=1 -s -n
...
==> This operation would free approximately 1.1GB of disk space.
like image 51
Gino Mempin Avatar answered Oct 14 '22 13:10

Gino Mempin