#827848 snapd: Purging snapd doesn't properly delete snapd from the system

#827848#5
Date:
2016-06-21 16:47:15 UTC
From:
To:
After purging snapd and restarting the system, ubuntu core is still
mounted automatically at boot:

$ mount | grep ubuntu
/var/lib/snapd/snaps/ubuntu-core_122.snap on /snap/ubuntu-core/122 type squashfs (ro,relatime)

After purging snapd I would expect this to no longer be the case.

#827848#10
Date:
2018-02-10 12:37:59 UTC
From:
To:
Dear Maintainer,

Purging snapd does not remove /snap/ directory due to leftover README
file. This file is provided by snapd package and I strongly believe it
should be removed by that package as well.

See terminal output below.

#v+
root@pingwin:~# aptitude install snapd
The following NEW packages will be installed:
  apparmor{a} snapd squashfs-tools{a}
0 packages upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/9503 kB of archives. After unpacking 45.4 MB will be used.
Do you want to continue? [Y/n/?] y
Retrieving bug reports... Done
Parsing Found/Fixed information... Done
Preconfiguring packages ...
(Reading database ... 286944 files and directories currently installed.)
Preparing to unpack .../apparmor_2.12-2_amd64.deb ...
Unpacking apparmor (2.12-2) ...
Selecting previously unselected package squashfs-tools.
Preparing to unpack .../squashfs-tools_1%3a4.3-4_amd64.deb ...
Unpacking squashfs-tools (1:4.3-4) ...
Selecting previously unselected package snapd.
Preparing to unpack .../snapd_2.30-4_amd64.deb ...
Unpacking snapd (2.30-4) ...
Setting up apparmor (2.12-2) ...
Setting up squashfs-tools (1:4.3-4) ...
Processing triggers for systemd (236-3) ...
Processing triggers for man-db (2.7.6.1-4) ...
Setting up snapd (2.30-4) ...
Created symlink /etc/systemd/system/multi-user.target.wants/snapd.autoimport.service → /lib/systemd/system/snapd.autoimport.service.
Created symlink /etc/systemd/system/multi-user.target.wants/snapd.core-fixup.service → /lib/systemd/system/snapd.core-fixup.service.
Created symlink /etc/systemd/system/timers.target.wants/snapd.refresh.timer → /lib/systemd/system/snapd.refresh.timer.
Created symlink /etc/systemd/system/multi-user.target.wants/snapd.service → /lib/systemd/system/snapd.service.
Created symlink /etc/systemd/system/timers.target.wants/snapd.snap-repair.timer → /lib/systemd/system/snapd.snap-repair.timer.
Created symlink /etc/systemd/system/sockets.target.wants/snapd.socket → /lib/systemd/system/snapd.socket.
Created symlink /etc/systemd/system/final.target.wants/snapd.system-shutdown.service → /lib/systemd/system/snapd.system-shutdown.service.
snapd.refresh.service is a disabled or a static unit, not starting it.
snapd.snap-repair.service is a disabled or a static unit, not starting it.

root@pingwin:~# ls /snap/
README
root@pingwin:~# aptitude purge snapd
The following packages will be REMOVED:
  apparmor{u} snapd{p} squashfs-tools{u}
0 packages upgraded, 0 newly installed, 3 to remove and 0 not upgraded.
Need to get 0 B of archives. After unpacking 45.4 MB will be freed.
Do you want to continue? [Y/n/?] y
(Reading database ... 287062 files and directories currently installed.)
Removing snapd (2.30-4) ...
Removing apparmor (2.12-2) ...
Removing squashfs-tools (1:4.3-4) ...
Processing triggers for man-db (2.7.6.1-4) ...
(Reading database ... 286949 files and directories currently installed.)
Purging configuration files for snapd (2.30-4) ...
Final directory cleanup
Discarding preserved snap namespaces
umount: /run/snapd/ns/*.mnt: no mount point specified.
umount: /run/snapd/ns/: no mount point specified.
Removing extra snap-confine apparmor rules
Removing snapd cache
Removing snapd state
dpkg: warning: while removing snapd, directory '/snap' not empty so not removed

root@pingwin:~# ls /snap/
README
root@pingwin:~#
#v-

#827848#15
Date:
2019-11-25 16:37:17 UTC
From:
To:
Now trying to purge snapd leads directly to an error:

$ sudo apt purge snapd
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  snapd*
0 upgraded, 0 newly installed, 1 to remove and 7 not upgraded.
After this operation, 61.0 MB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 394506 files and directories currently installed.)
Removing snapd (2.37.4-1+b1) ...
Processing triggers for mime-support (3.62) ...
Processing triggers for gnome-menus (3.31.4-3) ...
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for desktop-file-utils (0.23-4) ...
(Reading database ... 394456 files and directories currently installed.)
Purging configuration files for snapd (2.37.4-1+b1) ...
Stopping snap-core-8039.mount
Stopping unit snap-core-8039.mount
Waiting until unit snap-core-8039.mount is stopped [attempt 1]
snap-core-8039.mount is stopped.
Removing snap core and revision 8039
Removing snap-core-8039.mount
Final directory cleanup
Discarding preserved snap namespaces
Removing extra snap-confine apparmor rules
Removing snapd cache
rm: cannot remove '/var/cache/snapd/aux': Is a directory
dpkg: error processing package snapd (--purge):
 installed snapd package post-removal script subprocess returned error exit status 1
Errors were encountered while processing:
 snapd
E: Sub-process /usr/bin/dpkg returned an error code (1)