`snap remove` should reject commands with invalid snap names

Bug #1842203 reported by Merlijn Sebrechts on 2019-09-01
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
snapd
High
Unassigned

Bug Description

If you run `snap remove` with bad arguments, it currently assumes all arguments are snap names, regardless of whether these names are valid or not. As a result, slightly mistyping a `snap remove` command has very bad consequences.

Assume you refresh a snap to the latest version to see that it is broken. You revert to a previous revision and you want to remove the latest revision. This is what happens when you forget the two hyphens before `revision`.

```bash
merlijn@howard:~$ snap remove sdlpop revision=131
sdlpop removed
revision=131 not installed
```

Snap removes `sdlpop` entirely and tries to remove the snap `revision=131`. This causes irreversible damage since you can only revert to versions you have cached locally, so you lose the ability to use the previous working revision. This has already happened: https://forum.snapcraft.io/t/accidentally-removed-snap-package-how-to-revert-to-older-revision/12982?u=galgalesh

In order to prevent users from accidentally shooting themselves in the foot, `snap remove` should check if all arguments are valid snap names. If they are not, `snap remove` should error out.

John Lenton (chipaca) wrote :

The user data is not removed unless you also specified --purge (on reinstalling the app, 'snap restore sdlpop' would bring it back).

John Lenton (chipaca) wrote :

(sorry, 'snap restore' takes a snapshot id, use 'snap saved' to see the id)

description: updated
description: updated
Changed in snapd:
status: New → Confirmed
importance: Undecided → High
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers