Skip to content

Instantly share code, notes, and snippets.

@plembo
Last active February 16, 2024 16:40
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plembo/d80dbe492859b206033ad858e88a5247 to your computer and use it in GitHub Desktop.
Save plembo/d80dbe492859b206033ad858e88a5247 to your computer and use it in GitHub Desktop.

Removing snaps from Ubuntu 22.04 LTS

I don't currently use snaps, and have had to work hard at avoiding them [1]. So far the effort has been worth it, because Ubuntu has continued to provide a stable desktop Linux system that is compatible with a broad range of modern hardware.

Getting rid of snaps in Ubuntu 22.04 LTS is basically a 4 step process:

1. Remove snapd

$ sudo snap remove --purge firefox
$ sudo snap remove --purge snap-store
$ sudo snap remove --purge gnome-3-38-2004
$ sudo snap remove --purge gtk-common-themes
$ sudo snap remove --purge snapd-desktop-integration
$ sudo snap remove --purge bare
$ sudo snap remove --purge lxd
$ sudo snap remove --purge core20
$ sudo apt remove --purge snapd

2. Prevent reinstallation of snapd

Create /etc/apt/preferences.d/nosnap:

Package: snapd
Pin: release a=*
Pin-Priority: -10

3. Prevent the reinstallation of the snap version of a package

The example in this case is Firefox, but the principle applies to any .deb package that has a corresponding snap.

Create an apt preference for the package (here in a new /etc/apt/preferences.d/mozilla-firefox):

echo '
Package: *
Pin: release o=LP-PPA-mozillateam
Pin-Priority: 1001
' | sudo tee /etc/apt/preferences.d/mozilla-firefox

Add an exclusion to unattended upgrades (here in a new /etc/apt/apt.conf.d/51unattended-upgrades-firefox):

echo 'Unattended-Upgrade::Allowed-Origins:: "LP-PPA-mozillateam:${distro_codename}";' | sudo tee /etc/apt/apt.conf.d/51unattended-upgrades-firefox

4. Fix stuff that was dependent on snapd:

For Desktop systems, you have to restore gnome-software related packages:

$ sudo apt install --install-suggests gnome-software

To restore firefox (which in 22.04 is installed as a snap), you can either use the binary build from Mozilla like I do (see instructions at https://support.mozilla.org/en-US/kb/install-firefox-linux), or add the Firefox developer's PPA. Here's how to install the PPA:

$ sudo add-apt-repository ppa:mozillateam/ppa
$ sudo apt update
$ sudo apt install -t 'o=LP-PPA-mozillateam' firefox

Q & A

Q: What about dist-upgrade?

A: I guess we'll see when it comes to to 24.04 LTS.

Q: Wait. How did you reinstall Firefox?

A: At first I used the Mozilla Team PPA, but later I migrated to the binary package (just like in the good old days).

Q: But what will you do when Canonical removes apt and mandates the use of snaps for all software on Ubuntu?

A: Switch to Debian Stable, and pray they've resolved their hardware compatibility issues.

References

[1] Unlike the former Ubuntu community manager responsible for evangelizing snaps, I'm not convinced that flatpaks are the answer, particularly given their inability to properly deploy command line tools. Both apt and dnf (a/k/a yum) are quite capable (dnf having the edge in my mind with its built-in method for displaying history). What we really needed was for the distros to settle on one of those two as a standard, not create further confusion by introducing two more competing package managers that will only be used on -- at most -- 10% of computers.

Ji m. "How to Remove Snap Apps & Block Them in Ubuntu 22.04". UbuntuHandbook, 19 April 2022, https://ubuntuhandbook.org/index.php/2022/04/remove-snap-block-ubuntu-2204/.

Joey Sneddon. "How to Install Firefox as .Deb on Ubuntu 22.04 (Not a Snap)". OMG! Ubuntu!, 28 April 2022, https://www.omgubuntu.co.uk/2022/04/how-to-install-firefox-deb-apt-ubuntu-22-04.

Arindam. "How to Remove Snap Packages in Ubuntu Linux". Debugpoint.com, https://www.debugpoint.com/remove-snap-ubuntu/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment