valid,invalid

関心を持てる事柄について

brew cleanup でディスクの空き容量を増やす

brew は古くなった formula を自動的に消してくれないので、使い続けるほどにインストールしたパッケージが積もってディスクを圧迫する。

FAQ — Homebrew Documentation に書いてある brew cleanup を試したら 4GB ほどの空き領域を得られた。

How to use brew cleanup

# 特定の formula を消す
$ brew cleanup <formula>

# outdated な formula をまとめて消す
$ brew cleanup

# 削除対象の formula と得られる空き容量を確認する
$ brew cleanup -n

Read help

FAQ 以上の情報は help を見てみる。

$ brew cleanup -h

brew cleanup [--prune=days] [--dry-run] [-s] [formulae]:
    For all installed or specific formulae, remove any older versions from the
    cellar. In addition, old downloads from the Homebrew download-cache are deleted.

    If --prune=days is specified, remove all cache files older than days.

    If --dry-run or -n is passed, show what would be removed, but do not
    actually remove anything.

    If -s is passed, scrub the cache, removing downloads for even the latest
    versions of formulae. Note downloads for any installed formulae will still not be
    deleted. If you want to delete those too: rm -rf $(brew --cache)

新たにわかったこと

  • --prune=days で n 日以前のキャッシュを破棄できる。指定しない場合の記述がないが code を見るとデフォルトは14日のようだ。
  • -n--dry-run の 短縮形だった
  • -s で 最新の formula のダウンロードファイルも削除してキャッシュを掃除する。ただしインストールされたものについては消えない。これらも消したい場合は rm-rf $(brew --cache) を使う。

より詳細な挙動を追うならエントリーポイント実際の処理あたりを読むと良さそう。

環境