1. Overview
Snap is a software packaging system developed by Canonical primarily for use on Linux systems with the systemd init system. It aims to address a number of issues related to software packaging and distribution, but it also comes with its own set of drawbacks. In this tutorial, we’ll examine the downsides of using Snap and explore how to disable or remove it.
All commands have been tested on Snap 2.58.2 running on Ubuntu Desktop 22.04.02 LTS. However, they should also be compatible with most other Linux distributions.
2. Introduction to the Problem
While Snap provides several benefits, it also has some potential disadvantages, such as disk space usage, performance, and limited integration and customization.
Owing to these challenges and some controversial decisions that Canonical has made for the last few years, some distributions have disabled or removed Snap altogether from their releases.
2.1. Snap Disadvantages
Compared to traditional packaging systems like .deb or other formats like Flatpak and AppImage, Snap packages tend to occupy more disk space. Moreover, they are slower to launch since they require initialization of the runtime environment and loading of dependencies into memory.
Since Snap packages are self-contained and isolated from the host system, they offer limited integration with system resources and other applications. This can cause issues with accessing certain system resources, such as system themes and fonts.
2.2. Chromium Browser Controversy
Beginning with Ubuntu version 19.10, Canonical has mandated that users of Ubuntu and its derivatives utilize Snap to install Chromium. The chromium-browser .deb package now only includes wrapper scripts that facilitate the download of the Snap package.
As a result of this decision, Linux Mint removed Snap from its release package starting from version 20 – Ulyana. The apt command also prevents the installation of snapd.
2.3. Auto-Update and Auto-Upgrade by Default
By default, Snap performs four checks per day for updates and will automatically upgrade when available. However, this feature may cause problems for systems with limited resources. When resources such as RAM and CPUs are constrained, the operating system may terminate other critical processes in order to accommodate the auto-upgrade process.
2.4. Ubuntu Won’t Support Flatpak
Canonical has announced that it won’t be including Flatpak software in the Ubuntu package, starting from version 23.04 – Lunar Lobster, in an effort to encourage the use of Snap instead.
3. Removing and Disabling Snap
Let’s disable and remove Snap from our system.
On a fresh installation of Ubuntu 22.04.2 LTS, we have the following Snap version and packages pre-installed:
$ snap --version
snap 2.58.2
snapd 2.58.2
series 16
ubuntu 22.04
kernel 5.19.0-35-generic
$ snap list
Name Version Rev Tracking Publisher Notes
bare 1.0 5 latest/stable canonical✓ base
core20 20230126 1822 latest/stable canonical✓ base
firefox 110.0-3 2356 latest/stable/… mozilla✓ -
gnome-3-38-2004 0+git.6f39565 119 latest/stable/… canonical✓ -
gtk-common-themes 0.1-81-g442e511 1535 latest/stable/… canonical✓ -
snap-store 41.3-66-gfe1e325 638 latest/stable/… canonical✓ -
snapd 2.58.2 18357 latest/stable canonical✓ snapd
snapd-desktop-integration 0.1 49 latest/stable/… canonical✓ -
3.1. Removing Existing Snap Packages
Let’s now proceed to remove the Snap packages, or snaps, in the following order:
$ snap remove firefox
$ snap remove gtk-common-themes
$ snap remove gnome-3-38-2004
$ snap remove snapd-desktop-integration
$ snap remove snap-store
$ snap remove core20
$ snap remove bare
$ snap remove snapd
Before moving on to the next step, let’s ensure that the snaps list is empty:
$ snap list
No snaps are installed yet. Try 'snap install hello-world'.
If there were any snaps left, we could go back to listing them, and try to remove them with snap remove.
3.2. Removing snapd Daemon
Next, let’s stop, disable, remove, and hold the snapd daemon:
$ sudo systemctl stop snapd
Warning: Stopping snapd.service, but it can still be activated by:
snapd.socket
$ sudo systemctl disable snapd
Removed /etc/systemd/system/multi-user.target.wants/snapd.service.
$ sudo systemctl mask snapd
Created symlink /etc/systemd/system/snapd.service → /dev/null.
$ sudo apt purge snapd -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
snapd*
...
Removing snapd state
$ sudo apt-mark hold snapd
snapd set on hold.
The command ‘apt-mark hold‘ means that the package is marked as held back, which will prevent the package from being automatically installed, upgraded, or removed.
3.3. Removing Snap Package Directories
Snap stores all packages in the ~/snap/ directory by default. Let’s remove it:
$ rm -rf ~/snap/
Since the directory is in the home directory, we don’t need to use sudo to remove it. However, it’s important to be careful when typing the command as it will delete the directory recursively.
We should also make sure that the path ~/snap/ is correct.
3.4. Preventing Snap Installation Through the apt Command
Canonical changed the chromium-browser .deb package to now only include wrapper scripts that will trigger Snap installation.
To prevent such cases from happening, we can use the following command as suggested by Linux Mint:
$ sudo cat <<EOF | sudo tee /etc/apt/preferences.d/nosnap.pref
Package: snapd
Pin: release a=*
Pin-Priority: -10
EOF
As a result, when we try to install the Chromium browser using the apt command:
$ sudo apt install chromium-browser
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
chromium-browser : PreDepends: snapd but it is not installable
E: Unable to correct problems, you have held broken packages.
As we can see in the command above, Snap won’t be able to install itself without our consent.
3.5. Removing Any Leftover Snap Directories
If our system isn’t a fresh install, we may need to verify and delete some directories.
Let’s make sure we type these commands correctly, as we’ll be using sudo to delete the directories recursively:
$ rm -rf ~/snap
$ sudo rm -rf /snap
$ sudo rm -rf /var/snap
$ sudo rm -rf /var/lib/snapd
4. Conclusion
Through this article, we’ve explored the process of removing and disabling Snap from our system, as well as preventing it from being installed without our consent when using the apt command.
While Snap does offer a number of benefits, the approach taken by Canonical to promote its usage has not been well-received by the community and may ultimately result in the community avoiding Snap altogether.