Cleaning out Developer OSX in 2020

James Koh
3 min readSep 20, 2020

--

The dreaded system warning pops up: “Your disk is almost full”.

You’re in the middle of something and ignore that.Maybe you delete some files in downloads and desktop. Then move on (you know that’s not going to help).

A few days later… after the umpteenth warning, you start having to force quit applications. Then you look at Storage Tab. What’s in Documents? What’s in Other?

At this point, you start to realise you’re going to need to do something significant to remove the bloat on your system despite having “everything on the cloud”. So much for CI/CD!

🔮 The first thing is to reach for is the automated tools.

Docker

Docker can really hog the disk with a bunch of unused images, containers and volumes as we continuously try and test the latest images. While they do have very useful commands to purge everything unused with docker system prune that can also remove containers that you might still be using. So I would recommend going by the order of:

  1. Removing your unused containers (and their volumes with -v)
    docker container rm -v
  2. Removing the dangling images
    docker image prune
  3. Removing any volumes not previously removed
    docker volume prune

Android

The largest source of bloat that you can clear would be duplicity. Having multiple AVDs, multiple SDKs, multiple Gradle versions downloaded for different projects. If possible, decide on a common support level or drop AVDs when not in use.

  1. AVD Manager — Remove ununsed AVDs in
  2. SDK Manager — Remove unused AVD Images *Show Package Details
  3. SDK Manager — Remove unused SDKs
  4. Gradle — Remove unused ~/.gradle and .gradle versions.

XCode

There’s a real nifty tool to clean up XCode with DevCleaner for XCode. The main idea is to remove the old archives and unused simulators. Before that, you might need to decide on the version you would like to keep.

  1. Delete your old versions of XCode
  2. Run DevCleaner for XCode
  3. Use xcrun cli to delete unavailable simulators
    xcrun simctl delete unavailable
  4. Use xcrun cli to delete simulators you don’t develop for example watchOS
xcrun simctl list devices | grep -E -i "watch" | grep -E -o "([A-Z0-9]+-){4}([A-Z0-9]+)" | xargs xcrun simctl delete

NVM / Node

Clear out old versions of Node. I highly recommend using Node Version Manager if you haven’t.

  1. Find your old versions of node
    nvm ls
  2. Delete the unused versions
    nvm rm v10.16.3

Yarn / NPM

Package managers can hold a huge cache in efforts to speed up installations. Sometimes, they have really out of date caches, so clearing out the old packages becomes overdue. Be warned that the next time install is triggered, you might be in for a performance hit.

  1. yarn cache clean
  2. npm cache clean --force

Disk Utilities

A disk utility can identify hotspots that you might have overlooked, or verify that any of the above commands worked as expected. I’ve previously used Disk Inventory X but found DaisyDisk to be fast and up to task.

All the best 😄

--

--

James Koh
James Koh

Written by James Koh

yesterday was tough, make tomorrow better

No responses yet