Duplicate flatpak runtimes: user & system

When updating KDE Linux today, I noticed something new: I’d somehow accumulated both system and user flavors of several flatpak runtimes, consuming about 1.5GB more space than needed, and requiring duplicative refreshing/updating.

Resolving this wasn’t too hard. I removed flatpak apps that relied on the user flavor of each duplicate runtime, then removed the user runtime, then reinstalled the relevant apps. But…

KDE Linux is aimed at ordinary desktop users who may struggle with such things, or suffer in ignorance. I’m wondering how this sort of wasteful situation can be avoided going forward.

A per-user app is not limited to per-user runtimes: system-wide runtimes are available to all users, so it can use a runtime that only exists on the system side. The duplicates usually appear at install time, when Flatpak auto-installs the runtime next to the app even though the same one already exists in the other installation, and auto-download extension refs like GL drivers tend to follow the platform into both. What is real is the disk cost: the two installations are separate stores with dedup only inside each one, so a runtime kept in both really does occupy the space twice. The avoidance is to install everything the same way, and the Flatpak documentation recommends the system-wide default for day-to-day use. flatpak list shows which side each app and runtime sits in, and flatpak uninstall --unused clears runtimes nothing references; moving one app only frees its duplicate if nothing else on that side still uses the runtime.

Thanks for this response, Rei. My man page reading suggested that flatpaks install as system by default. That didn’t happen when I installed several flatpaks via Discover, which apparently does user installations by default, at least on KDE Linux.

That is not the case, in my limited experience, for Kubuntu or Kinoite.

At the moment, defaulting to user installation seems like a bad thing. My question is now: can and should Discover install flatpaks as system by default on KDE Linux?

Your man page reading is right: the flatpak command installs system-wide by default, and --user is what makes it per-user (Flatpak’s Using Flatpak doc). So if you want a system-wide install today, the CLI is the way to get it. Whether Discover on KDE Linux can be switched to system-by-default I can’t verify; I don’t know of such a setting. On the “should”: on a single-user machine user installs work the same, so I’d treat the default as preference rather than a problem. System-wide mainly matters when several accounts share one machine, where it also avoids storing every runtime twice.

Yes, but… Even on my single-user machine, I ended up with both system and user flatpak runtimes, which is undesirable.

I don’t mind default user flatpaks, but I do mind duplicate runtimes and I wonder if KDE Linux is somehow especially prone to that situation, which would be an opportunity for improvement. I haven’t seen the duplication occur on other distros.

I’ve poked around a bit, but I’m unable to see where/how Discover’s flatpak backend is configured. Perhaps there’s a non-obvious option in KDE Discover’s flatpak backend. Perhaps it’s melted into the KDE Linux implementation of KDE Discover. Dunno.

command line does the same if there is a “per-user” remote configured.

As I had the same annoying “download almost every runtime twice”, in the past as well. using the Terminal for updates.

After removing every user runtime I figured out that a flatpak remote-list showed not only “flathub system” but also a additional user remote (in my case it was the Gimp 3 beta I had added to give a try when it was near the finish line) that triggered flatpak to double up on the runtimes. After removing (flatpak remote-delete --userREMOTE-NAME) that as well and flatpak remote-list now only outputting “flathub system” no more huge double downloads. And even some flatpaks I installed later using Discover are system installations.

Although I am not on KDE Linux or atomic Distro, not sure if “per-user” is somehow a requirement of those.

Interesting. It occurs to me that the packaging of individual flatpak apps may influence whether “user” is the default. Now that I’m paying attention, I see different apps defaulting to either “flathub (user)” or just plain “flathub” (which apparently means system).

If so, this may not be a Discover issue, or a plasma-discover-backend-flatpak issue. It still seems troublesome. Overall, I’m loving flatpaks though.

If your system is set up with both system and user Flatpak install destinations, it’s an issue in Discover, yeah: https://bugs.kde.org/show_bug.cgi?id=518765

I thought KDE Linux shipped out of the box with only the system destination, though. Did you knowingly or unknowingly add the user destination yourself?

Nate,

Thank you for this hint. I’ve dug further. The user/system issue now appears to be my user error. It’s likely that I unwittingly stumbled into adding a user destination while adding a KolourPaint flatpak, one of several flatpak apps that ended up user rather than system. .histfile shows that I used this command, copied from KolourPaint - KDE Applications

flatpak install --user --or-update https://cdn.kde.org/flatpak/kolourpaint-nightly/org.kde.kolourpaint.flatpakref

Why did I do this? Likely, a desire to avoid adding an older org.kde.Platform runtime that KolourPaint requires. But that would have been preferable to the user/system duplication I later noticed.

If I had removed the --user option and said no to the question, “Should the remote be kept for future installations,” I would have avoided the later duplication. Indeed, maybe just removing --user would have been enough to skip past this educational rabbit hole.

I’m loving flatpak and KDE, but I still fall into traps for the unwary. :roll_eyes:

Yep, accidentally adding a user repo is indeed a bit of a free space footgun here. Discover doesn’t to enough to warn you about it, in addition to not honoring your preference later. Areas to improve, for sure!