'snap install' neither updates to the request channel, nor returns an error, if snap is already installed
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
snapd |
Triaged
|
Wishlist
|
Unassigned |
Bug Description
Sometimes you want to make sure a snap uses a specific channel in a script. A common attempt is:
snap install --channel=
Now that works if lxd isn't installed. But if lxd is installed and tracking a different channel, that command will succeed, but it won't refresh to the requested channel.
root@test:~# snap info lxd | grep installed
installed: 4.0.8 (21835) 70MB -
root@test:~# snap info lxd | grep latest/stable
latest/stable: 4.22 2022-01-26 (22292) 79MB -
root@test:~# snap install --channel=
snap "lxd" is already installed, see 'snap help refresh'
root@test:~# echo $?
0
root@test:~# snap info lxd | grep installed
installed: 4.0.8 (21835) 70MB -
I do know about 'refresh'. But given that the 'install' didn't produce an error, you often won't catch it, until you notice that something else is not working as expected.
At the very least, it would be nice if it would produce an error, so you can catch it early. But it would also be nice to have a way to ensure a snap is tracking a certain channel, which works both when the snap is installed, and when it's not installed.
oot@test:~# snap version
snap 2.53.4
snapd 2.53.4
series 16
ubuntu 20.04
kernel 5.13.0-27-generic
That's technically easy to change and I can see how this simplifies the scenario you described, but I fear that is a behavior change that may break someone, so not sure we will want to change this, to be discussed.