Ubuntu: Get Rid of Snap
Views: 44
Since a few releases, Ubuntu has introduces snap as package manager for some software, instead of using apt repositories. Snap has many disadvantages. Instead of referncing dependencies from other packages, everything is packed into one package and then run in a sandbox. Not only that this results in larger and redundant deployments, due to the sandbox, several concept fail. A system like snap, similar to docker, is fine for distributing micro services in a cloud, but not for local package management. It’s the duty of the packager (Ubuntu), to keep all dependencies consistent. They are just too lazy!
Steps to Take
To completely remove snap:
- Remove all installed Snap Packages
snap list | tail -n +2 | cut -f1 -d' ' | xargs -i sudo snap remove --purge {}
- Remove Snap from the Apt Installation
sudo apt autoremove --purge snapd
- Prohibit Re-Installation of the Snap Package
Create file:/etc/apt/preferences.d/no-snap
- Install Software Using Apt
Remove all Installed Snap Packages
The first step is to remove all installed snap packes. To see a list of installed packages, call snap list
, e.g. on my installation, so:
snap list
On my system (after I already removed firefox, thunderbird and chromium), it shows:
Name Version Rev Tracking Publisher Notes bare 1.0 5 latest/stable canonical? base code fee1edb8 167 latest/stable vscode? classic core20 20240416 2318 latest/stable canonical? base core22 20240731 1564 latest/stable canonical? base cups 2.4.10-1 1058 latest/stable openprinting? - firmware-updater 0+git.5007558 127 latest/stable/… canonical? - gnome-42-2204 0+git.510a601 176 latest/stable/… canonical? - gtk-common-themes 0.1-81-g442e511 1535 latest/stable/… canonical? - icon-theme-breeze 1.0 2 latest/stable kde? - snap-store 0+git.1419621 1124 latest/stable/… canonical? - snapd 2.63 21759 latest/stable canonical? snapd snapd-desktop-integration 0.9 157 latest/stable/… canonical? -
You can either manually remove them one by one, e.g. calling sudo snap remove --purge code
`, or you can run a script, that tries to remove all of them one by one:
snap list | tail -n +2 | cut -f1 -d' ' | xargs -i sudo snap remove --purge {}
On my system, this outputs some errors:
error: cannot remove "bare": snap "bare" is not removable: snap is being used by snaps gtk-common-themes and icon-theme-breeze. code removed core20 removed error: cannot remove "core22": snap "core22" is not removable: snap is being used by snaps cups, firmware-updater, gnome-42-2204, snap-store and snapd-desktop-integration. cups removed firmware-updater removed gnome-42-2204 removed gtk-common-themes removed icon-theme-breeze removed snap-store removed error: cannot remove "snapd": snap "snapd" is not removable: remove all other snaps first snapd-desktop-integration removed
As you see, not all have been removed immediately because of dependencies, so you simply run the command a second time:
snap list | tail -n +2 | cut -f1 -d' ' | xargs -i sudo snap remove --purge {}
This time all have been remove. Otherwise you’d just call it a third time.
bare removed core22 removed snapd removed
Remove Snap from the Apt Installation
Now it’s time to remove snap from the apt package installation:
sudo apt autoremove --purge snapd
At the end, I see some errors:
Final directory cleanup rm: cannot remove '/var/snap': Device or resource busy Cannot remove directory /var/snap Removing extra snap-confine apparmor rules Removing snapd cache Removing snapd state dpkg: warning: while removing snapd, unable to remove directory '/var/snap': Device or resource busy - directory may be a mount point?
This is, because I installed on ZFS, and it seems to create a separate mount point. It can be cleaned-up:
Get the name:
mount | grep snap
I get:
rpool/ROOT/ubuntu_7yzrbz/var/snap on /var/snap type zfs (rw,relatime,xattr,posixacl,casesensitive)
So the name of the ZFS resource is rpool/ROOT/ubuntu_7yzrbz/var/snap
. Now I can remove it:
sudo umount /var/snap sudo zfs destroy rpool/ROOT/ubuntu_7yzrbz/var/snap sudo rm -rf /var/snap
Prohibit Re-Installation of Snap Package
In apt configurations, set Pin-Priority
to a very low value for Package snapd
to prevent it’s installation:
cat <<EOF | sudo tee /etc/apt/preferences.d/no-snap Package: snapd Pin: release a=* Pin-Priority: -10 EOF
Then the file contains those three lines:
marc@saturn:~$ cat /etc/apt/preferences.d/no-snap Package: snapd Pin: release a=* Pin-Priority: -10
Install Software Using Apt
After adding a repository, always first call sudo apt-get update
to read the new sources.
Mozilla Firefox
You may install firefox from the mozzilla team’s PPA and set the priority to a higher level, e.g. 1001
:
sudo add-apt-repository ppa:mozillateam/ppa sudo apt-get update cat <<EOF | sudo tee /etc/apt/preferences.d/mozilla-firefox Package: * Pin: release o=LP-PPA-mozillateam Pin-Priority: 1001 EOF
Then you can install firefox from the apt packages:
sudo apt-get install firefox
Chromium Browser
For the chromium (open source version of Google chrome) browser, I found a PPA repository:
sudo add-apt-repository ppa:xtradeb/apps -y sudo apt update sudo apt install chromium
Visual Studio Code
Visual Studio Code on Linux writes:
Installing the .deb package will automatically install the apt repository and signing key to enable auto-updating using the system’s package manager.
So simply download and install the debian package, for that give global access and install, e.g.:
chmod ugo+r /home/marc/Downloads/code_1.92.2-1723660989_amd64.deb sudo apt-get install ~/Downloads/code_1.92.2-1723660989_amd64.deb
References
My thanks go to: