Skip to main content

Clear Pacman Package Cache

·238 words·

Yesterday, I experienced my first system break since I started using Arch Linux. On boot, my machine displayed a cryptic message, “Trying to remove unit with unsupported extension conf”, and got stuck at the TTY interface, failing to auto-start Hyprland.

My immediate suspicion fell on the session launcher, uwsm. After some investigation, it turned out I was right—the newly updated version 0.23.1 was indeed buggy.

I decided to try downgrading to version 0.23.0. I ran ls /var/cache/pacman/pkg/ | grep uwsm to check my local cache and was surprised to find a sprawling list of a dozen or so versions of uwsm just lying there. A quick “vibe check” on Google revealed that, as it turns out, pacman doesn’t automatically clear its downloaded packages. That’s when I realized I needed to learn how to manage it myself.

Fortunately, pacman provides an official companion tool for this very purpose: paccache (which comes with the pacman-contrib package).

The standard cleanup method, paccache -r, scans the cache directory and keeps the three most recent versions of each package, deleting anything older. For a more aggressive approach, paccache -rk1 keeps only the single, currently installed version.

Of course, you can also automate this. paccache comes with a systemd timer, which can be enabled with sudo systemctl enable --now paccache.timer. This will schedule a weekly job to run paccache -r automatically.

My first manual cleanup freed up around 12GB of space—a pretty significant amount!