Multiple old versions of old snaps installed. Why?

Hi,

I installed intellij via snap and I checked my installed snaps with ls -lh /var/lib/snapd/snaps/ and it now shows 2 versions of intellij installed? image

shouldn’t it uninstall old versions automatically?

A couple of older versions are kept in case you need to revert should the new revision be broken. By default, on desktop a single old revision is retained. Please see https://snapcraft.io/docs/keeping-snaps-up-to-date#heading--refresh-retain for details

I generally agree with the overall issue. In practice a revert is only needed when an update goes bad. So maybe snapd could use some intelligence here and remove old revisions with a delay of a few hours ? Keeping extra revisions on laptops/computers does serve too much IMO.

Alternatively, the snapd could consider my proposal here Proposal: Use casync for delta updates to limit the old revision cruft

Agree. I can deal with snaps being bigger than they need to be but having half of the storage of the install be wasted seems pretty bad. @mborzecki are there any plans to allow disabling the retain feature?

There is not currently a plan to allow fully disabling the retaining of old revisions. We also don’t want to delete revisions after the refresh has completed with some sort of “intelligence” because we’ve had numerous high profile snaps that push out a bad update that is bad in such a way that it is not realized until a day or two after the refresh happened (sometimes later), and we always want the ability to suggest to folks if a snap doesn’t work to:

  1. check if the previous revision works using snap revert <snap>
  2. check if a newer revision works using snap refresh <snap> --beta etc

So any sort of intelligence we try to encode into snapd about when to get rid of old revisions will end up being wrong.

We may consider a more storage efficient mechanism for keeping older revisions around in the future, but we don’t intend to get rid of their existence entirely (locally on the user’s machine by default specifically).

Finally, note that if you really don’t care about being able to revert to previous revisions, you can always manually remove old revisions with snap remove <snap> --revision=<rev> where the old revision numbers can be seen with snap list <snap> --all.

Is there some way to retroactively clean out really old revisions of all snaps after setting refresh.retain to a small value like, say, 3?

I currently have many revisions of many snaps and if I decide I really need only up to 3 of everything, I can run:

$ snap set system refresh.retain=3

But is there some subsequent command I can run that will then scour all of my installed snaps and trim them down to match that value? I mean, other than manually removing them one at a time?