How do I remove old versions of my snap from the store(s)

I have a published public snap. The store includes many old versions of my snap. How can I remove these versions so that users do not install an old version?

I thought that all snap packages self-upgrade (i.e. refresh) themselves by default? User won’t get old versions unless explicitly requested.

Snap packages do auto update. However, I have had users explicitly install the old versions and then complain that features are not working.

TL;DR If you have an old version of your snap released to edge, beta or candidate, and users are installing with --channel= and getting “stuck” on that version because you’re not pushing updates to that channel, you can close that channel, and users will automatically refresh to the next most stable channel that has a released snap. Example:

snapcraft close your-snap edge
snapcraft close your-snap beta
snapcraft close your-snap candidate

this will close all channels other than stable and all users will update to the version that’s available on stable.

Long explanation

Publishing snaps requires two operations: first you push the actual package (which creates a “revision” in the store) and then you release that package you pushed, to any of the four well-known channels (edge, beta, candidate, stable). Users can then snap install your snap. Without any parameters, this will install the revision that’s available on the stable channel. Or, they can specify a channel with --channel=.

Once installed from a particular channel, the snap will only update to revisions that are released on that channel. That is, if you release revision 10 of your snap to beta, then release revision 11 of your snap to stable, then users who installed with --channel=beta will not be updated to revision 11. If later you relase revision 12 to beta, then users who installed from beta will get revision 12.

Note that users cannot install a snap by a specific revision number:

$ snap install sutil --revision 111
error: cannot install "sutil": Access by specifying a revision is not allowed
       for this Snap.

So my guess is your users are installing using --channel as described above.

The solution

What you can do is close the channels where old revisions of your snap are available. Snaps have a “fallback” behavior where, if the channel where the snap was installed from is closed, they will refresh from the most stable channel that does have a revision available. For example, if you have an old version of your snap in edge:

$ snap info hello-roadmr-1
name:      hello-roadmr-1
  stable:    2017-06-04-04 (35)  4kB -
  candidate: ↑                      
  beta:      ↑                      
  edge:      2018-06-04-01 (33) 4kB -

you can simply close it:

$ snapcraft close hello-roadmr-1 edge
Track    Arch    Channel    Version        Revision
latest   amd64   stable     2017-06-04-04  35
                 candidate  ^              ^
                 beta       ^              ^
                 edge       ^              ^

Notice how edge has arrows pointing to beta, which points to candidate, which points to stable, which finally has a snap released into it.

Now, any users who had installed from edge, when refreshing, will get the version that is in stable, and will actually start tracking the stable channel instead of edge:

$ snap refresh hello-roadmr-1
hello-roadmr-1 2017-06-04-04 from 'roadmr' refreshed
Snap hello-roadmr-1 is no longer tracking edge.

Incidentally, for users, the output of snap info shows, with the arrows, which channels are closed and following another channel:

$ snap info sutil
name:      sutil
  stable:    0.1 (1) 9MB -
  candidate: ↑           
  beta:      ↑           
  edge:      0.1 (5) 9MB -

For example, this snap has revision 1 on stable, and revision 5 released on edge, but nothing on beta or candidate. Thus, a user doing snap install --channel-candidate sutil will get what is released in stable and be updated as new releases get to that channel.