9

I can purge a snap package with

snap remove --purge myPackage

But what if I already removed it, without the --purge flag? With apt, I can still do sudo apt purge myPackage, even after an uninstall, but not with Snap, it seems. Do I have to install it again, to remove it a second time with the purge flag, or is there another way I missed?

1
  • 2
    The behavior of 'remove' is not similar. To oversimplify: snap remove Foo is already roughly equivalent to apt purge Foo
    – user535733
    Aug 16, 2022 at 18:08

2 Answers 2

8

purge does not what you expect: it disables snapshots. snap has a remove option to delete leftovers.

From the help:

$ snap help remove
Usage:
  snap remove [remove-OPTIONS] <snap>...

The remove command removes the named snap instance from the system.

By default all the snap revisions are removed, including their data and the
common data directory. When a --revision option is passed only the specified
revision is removed.

Unless automatic snapshots are disabled, a snapshot of all data for the snap is
saved upon removal, which is then available for future restoration with snap
restore. The --purge option disables automatically creating snapshots.

[remove command options]
      --no-wait     Do not wait for the operation to finish but just print the
                    change id.
      --revision=   Remove only the given revision
      --purge       Remove the snap without saving a snapshot of its data

So a remove without a purge does the same except for saving a snapshot. You can still do a remove with a --revision= will remove that revision. Or find the snapshots on disk and delete those ;)

7

See what the Snap Docmentation tells us about removing snaps.

The only difference is a snapshot of user-data and configuration-data which is only taken when you don't use the --purge-option. This snapshot will be kept for 31 days.

So you don't really need to do anything, the snapshot will be removed after that period by the snapd service.

If you are somehow in a hurry or the snapshot contains sensitiv data which you want to remove as soon as possible, take a look with snap saved for existing snapshots and use snap forget to remove a snapshot. Example:

~$ snap saved
Set  Snap  Age    Version    Rev  Size    Notes
4    wire  14.8d  3.24.2939  237   982kB  -
~$ snap forget 4
Snapshot #4 forgotten.
~$ snap saved
No snapshots found.

Feel free to take a deep look into man snap.

Just for completeness: Snapshots are stored as zip-archives in /var/lib/snapd/snapshots/.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .