Cleaning up macOS bloat

Freeing up disk space on macOS, particularly caches that usually never get purged.

Development packaging caches

Ruby

~/.gem contains gem-installed package information for each version of Ruby

rm -rf ~/.gem

Python

~/Library/Caches/pip contains packages cached by pip

Java

~/.m2 contains Maven repository information

rm -rf ~/.m2/

~/.ivy2/cache contains Java package jars and metadata for Maven/SBT-installed packages

rm -rf ~/.ivy2/

~/.sbt contains Scala Simple Built Tool’s caches

rm -rf ~/.sbt/

~/Library/Application Support/Java contains all previously installed Java packages

rm -rf ~/Library/"Application Support"/Java/*/

Haskell

~/.cabal/setup-exe-cache contains cabal executables for OS X (Haskell)

rm -rf ~/.cabal/setup-exe-cache

~/.cabal/packages contains cached index and cabal-installed tarballs (Haskell)

rm -rf ~/.cabal/packages/

~/.stack/indices contains cached index and stack-installed tarballs (Haskell)

rm -rf ~/.stack/indices

~/.stack/setup-exe-cache contains cabal executables for OS X (Haskell)

rm -rf ~/.stack/setup-exe-cache

~/.stack/snapshots contains ghc tooling, binaries, documentation (Haskell)

rm -rf ~/.stack/snapshots

JavaScript

~/.bower contains Bower’s cache of git repositories

rm -rf ~/.bower ~/.cache/bower

~/.node-gyp contains gyp build files for each version of Node.js

rm -rf ~/.node-gyp

~/.npm contains the npmjs repository cache

npm cache clean

Miscellaneous

~/.vagrant.d/boxes contains Vagrantfile box information

rm -rf ~/.vagrant.d/boxes

~/.cocoapods contains the CocoaPods cache (iOS/OS X dev)

rm -rf ~/.cocoapods

~/.cache/youtube-dl contains “sigfunc” data that youtube-dl keeps around (or used to?)

youtube-dl --rm-cache-dir

spaCy downloads raw data to a cache directory but doesn’t clean up after unpacking. This removes just the downloaded archives, not what spaCy actually uses:

rm -rf /usr/local/lib/python2.7/site-packages/spacy/data/__cache__

Browsers

Firefox

  • Preferences →
  • Advanced (left nav, bottom option) →
  • Network (top horizontal nav) →
  • “Clear Now” (button)

Chrome

  1. Open dialog:

    • Preferences →
    • Settings (left nav) →
    • “Show advanced settings…” (link at bottom of page) →
    • “Clear browsing data…” (button in Privacy section)

    or:

    • command+shift+delete
  2. Run action:

    • Choose “the beginning of time” (dropdown) →
    • “Cached images and files” (checkbox) →
    • “Clear browsing data” (button)

Safari

  • Preferences →
  • Privacy (navbar tab) →
  • “Manage Website Data…” (button) →
  • “Remove All” (button)

(Apparently there’s no option to clear only the caches but not cookies and history.)

Xcode

DerivedData/ contains the intermediate build files for Xcode projects. Can also be deleted from within Xcode → “Window” → “Projects” → …select a project → “Delete…”

rm -rf ~/Library/Developer/Xcode/DerivedData/*

iOS DeviceSupport/ contains symbols for each architecture of devices that have been connected. Safe to delete all of them, and sane to delete all but the current deployment target(s).

trash ~/Library/Developer/Xcode/iOS DeviceSupport/*/

CoreSimulator/Devices contains partial per-Device information for simulation. These are easy to replace, so it’s safe to delete the ones you aren’t using, but they don’t take up that much space anyway (~500MB total). Can also be deleted from within Xcode → “Window” → “Devices” → …right click a device → “Delete”

trash ~/Library/Developer/CoreSimulator/Devices/*/

Profiles/Runtimes contains actual simulator runtimes, which can weigh in at 2GB+. These can be reinstalled any time within Xcode → Preferences → “Components” → “Simulators” → …click the download icon

trash /Library/Developer/CoreSimulator/Profiles/Runtimes/*/

Mac OS X install extras

Dictionaries for other languages:

trash /Library/Dictionaries/*{Chinese,Duden,Dutch,French,German,
                              Hindi,Italian,Korean,Norwegian,
                              Portuguese,Russian,Sanseido,
                              Spanish,Swedish,Thai,Turkish}*