Does anyone know why the directory at $HOME/.local/share/flatpak/repo
contains so many files (69 k) and is so huge (2 Gb) ? What is that ? I hardly ever use flatpaks anyway....
I guess it is not important to include the flatpak directory in one's backup (deja-dup).
PS it looks like there are hard links inside because the flatpak folder has got twice as many files but the same total size.
Flatpak packages runs in sandbox mode: so, by design, flatpak takes a considerable amount of disk space for an individual application, even if it is a smaller one, because it pulls all dependencies for an app and runs independently. The advantage of this design is taht you do not need to worry about dependencies and updates of the system that may break your app. However, it takes up huge amount of disk space.
As a consequence, the only thing that a user can do is to monitor flatpak size and perform a periodic clean. Personally, I have a script called "spring-cleaning" that I use periodically to perform a cleaning of the system (and within it there is a section related to flatpak).
Generic cleanup
flatpak list --app --columns=application,runtime
lists which app use which runtime), you can remove it withflatpak uninstall --unused
. This is a cleanup that may have a great effect the first time you run it, but as you can imagine the cleanup may not be significative after the first use./var/lib/flatpak/repo/objects
folder, that may reach a significative size. To prune these objects (that don't have an explicit reference to their app), you need to run (withsudo
, because you are cleaning objects in a system folder)sudo flatpak repair
. The impact of this cleanup may be significative every time you run the command.sudo rm -rfv /var/tmp/flatpak-cache-*
andrm -rfv ~/.cache/flatpak/*
Specific cleanup
flatpak --columns=name,size --user list
and then uninstall an app using its nameflatpak uninstall <flatpak_app_name>
Combining in a script (to run with sudo)
Flatpaks are "sandboxed", meaning that any app caches, large libraries, etc. that the app needs are stored in those directories. This means that the file sizes for these directories are often horribly large.
To clean this up, use
flatpak uninstall <package>
. See more aboutflatpak uninstall
here.