1

I'm considering replacing snap with flatpak. What happens during a version upgrade of Ubuntu? Is the Ubuntu upgrade programmed to reinstall snap and what is the risk of pinning or holding snap from being reinstalled?

I would like to avoid having to purge snap on every upgrade and don't want to risk ending up with a broken system because some key system component has become a snap package.

To Do
  • 15,833

1 Answers1

3

apt gives the chance to pin a package. Further details about pinning are available using the terminal command man 5 apt_preferences.

The "Pin-Priority" parameter, in your specific case, can be used to prevent the re-installation of snapd package by giving it a negative priority.

Create a file no-snap.pref by issuing in a terminal:

sudo -H gedit /etc/apt/preferences.d/no-snap.pref

and then copy the following content in it:

# To install snapd, specify its version with 'apt install snapd=VERSION'
# where VERSION is the version of the snapd package you want to install.
Package: snapd
Pin: release a=*
Pin-Priority: -10

You can still install snapd if you want, but you need to explicitly set the package version in the sudo apt install command: you don't need to delete the /etc/apt/preferences.d/no-snap.pref file.

I've tested this procedure from 20.04 to 20.10 + 20.10 to 21.04 + 21.04 to 21.10 transitions. However, consider that for the GNOME variant of Ubuntu, the number of packages distributed as snap is increasing, and for some of them the decision has been taken not by Canonical but by the package distributor itself (for instance, Mozilla for firefox). In the future the removal of snapd may not be harmless.

Pablo Bianchi
  • 17,371
Lorenz Keel
  • 9,511