`snap revert` reverts the snap revision, but not the tracked channel


I have a question regarding the handling of tracking channels when using the snap revert command.

I have a Raspberry Pi 4 running Ubuntu Core 22. As of today, the pi gadget snap is tracking 22/stable channel, and it’s using revision 132:

# snap info pi
tracking:     22/stable
  22/stable:        22-2   2022-06-10 (132) 11MB -
  22/candidate:     22-2   2022-06-10 (132) 11MB -
  22/beta:          22-2   2022-06-10 (132) 11MB -
  22/edge:          22-2   2023-01-09 (137) 11MB -
installed:          22-2              (132) 11MB gadget

Let’s say I now want to refresh to the latest revision in the edge channel. I run the following command (I know --revision=137 is not mandatory, but I am writing a script and I need to have this parameter filled):

# snap refresh pi --channel=22/edge --revision=137
# snap list pi
Name  Version  Rev  Tracking  Publisher   Notes
pi    22-2     137  22/edge   canonical✓  gadget

All good. The pi snap is now using revision 137 and tracking the 22/edge channel.

Let’s assume there is a problem, though, and I want to revert to the previous “safe” environment (rev 132, 22/stable channel). I issue the revert command:

# snap revert pi
2023-09-12T03:35:04Z INFO No gadget assets update needed
pi reverted to 22-2

# snap list pi
Name  Version  Rev  Tracking  Publisher   Notes
pi    22-2     132  22/edge   canonical✓  gadget

The snap was indeed reverted to revision 132 (OK), but it’s still tracking channel 22/edge (not OK!).

Is there a way to tell snapd to revert not only the snap revision, but also the tracking channel?


I could not find any way to switch the channel without actually performing a refresh.

Not sure about your usecase, but you could perform a refresh using the previous channel directly after reverting.

snap switch --channel does that, it is mentioned in quickstart.

1 Like

Good to know. I managed to confuse my installation by trying to trick it into refreshing without updateing by using some unholy --hold --refresh combinations