Removing unneeded runtimes and dependencies from Flatpak
Throughout last year I was in a Libre gaming spree where I tried multiple FPSes and other games for Linux, resulting in many-a-different videos in my Peertube Channel. Lotsa fun was had, though I realize that I suck in some kinds of games, and learning to record a podcast was nice.
Since not every game I wished to play was available in Arch or the AUR, I used Flatpak to standardize most of the installs, and not end up with a bunch of different and potentially incompatible dependencies around. This was also much faster than manually compiling them from source, which is how some of less frequently updated applications like games are provided via the AUR.
There was one significant byproduct from this venture, though: significant usage of disk space. Where Flatpak was efficient in organizing these dependencies and sandboxing them, it did have the side effect of increasing disk usage as entire runtimes had to be installed at times instead of the smaller native shared libraries of my package manager.
It was of course quite subtle in the beginning, but as I played more games, I couldn't help but noticing that
df started to report an increasingly smaller available disk space. Even Project 128 efforts did not seem to help much. And when I gauged the size of such runtimes, it became clear where disk space was going to.
Flatpak has useful and quite straightforward command-line arguments to manage your installations, but here's the thing: when you uninstall a flatpak app, it doesn't automatically uninstall dependencies or runtimes, even when it's clear that there are no apps that require them in the current system. That was why while I went ahead to uninstall the games I no longer play, the actual freed space did not seem to change significantly.
So, do I manually hunt down unused runtimes and purge them at will, at risk of damaging something if I mess up? Thankfully, no - there is a way of deleting them automatically. Here's it:
flatpak uninstall --unused
Running that after you explicitly
uninstall something will purge any left dependencies that have no other use in the system. Note that some of these may include things like entire GNOME or KDE environment runtimes, which easily consume upwards to a few GB in disk size. This way, you can more or less roll back the flatpak environment back to what it was before you installed whatever program you wanted to try - and freed away a significant part of my hard drive.
This maneuver completed the circle of using flatpak for me. It made the whole system a much simpler, saner and quicker way to manage applications that for some reason aren't very well integrated into the package manager of your distribution. No more fear of trying out new programs and no headache to uninstall them!
Perhaps there are better ways to manage specific programs besides the main package manager in Linux (I hear that Guix, Nix, or AppImage are pretty good for this too). For now, however, I'm sticking with Flatpak and its repositories. Carry on!
How is your experience with Flatpak or other secondary package managers alongside your distro's main one? Do you have any tips about using them? Let me know on Mastodon!
Source for this post: Linux Uprising
This post is number #31 of my #100DaysToOffload project. Follow my progress through Mastodon!
Last updated on 01/26/22