52

sudo apt-get install chromium-browser for some reason installs not a proper apt-get package but is installing the chromium snap.

I am aware that blocking such installs will not magically establish a maintained package, and would result in an installation failure. But I prefer to get error and install manually - from source or in unlikely cases from snap.

I want to never install anything using snap (for start, due to Snap Store closed-source practice). Especially not silently when I install using apt-get.

How can I disable snaps in gnome-software centre? is not answering my question as I want to get rid of snap infestation in apt - not in gnome-software-center.

muru
  • 207,228

2 Answers2

40

You have to remove snapd from the system by

sudo apt-get autopurge snapd

and then create special configuration file for APT, as LinuxMint did:

cat <<EOF | sudo tee /etc/apt/preferences.d/nosnap.pref
# To prevent repository packages from triggering the installation of Snap,
# this file forbids snapd from being installed by APT.
# For more information: https://linuxmint-user-guide.readthedocs.io/en/latest/snap.html

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

This will prevent Snaps installation in future.

N0rbert
  • 103,263
7

Besides setting files in /etc/apt, you can run apt-mark to prevent anything requiring snapd from installing, just after purge snapd:

$ sudo apt-mark hold snapd

For example, installing firefox in Ubuntu 22.04 (which is a snapd-based package) gives you an error:

$ sudo apt install firefox
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: firefox : PreDepends: snapd but it is not going to be installed E: Unable to correct problems, you have held broken packages.

The only way to break this rule is to do it explicitly:

$ sudo apt install snapd
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  snapd
The following held packages will be changed:
  snapd
0 upgraded, 1 newly installed, 0 to remove and 11 not upgraded.
Need to get 23.8 MB of archives.
After this operation, 102 MB of additional disk space will be used.
Do you want to continue? [Y/n]

Also, you can undo the effect via:

$ sudo apt-mark unhold snapd