1

I am trying to prevent APT from installing any Snap-based packages on my system. For example, some packages are offered as Snap versions with names like the following:

  • Firefox: 1:1snap1-0ubuntu5
  • Thunderbird: 2:1snap1-0ubuntu3
  • Chromium-browser: 2:1snap1-0ubuntu2

I want to block or lower the priority of all such Snap versions so that APT defaults to .deb packages from other repositories or PPAs. However, the method I tried so far hasn't worked.

I created a snap.pref file in /etc/apt/preferences.d/ folder with the following content:

Package: *
Pin: version *snap*
Pin-Priority: -1

However, apt responded with W: Did not understand pin type version and didn't update the priority for Snap-based packages.

Can you suggest the right way to do this?

AvidCoder
  • 115

1 Answers1

2

I was in search for this exact matter, and I managed to solve it like this:

( by using a regular expression and not a glob, both in 'Package:' and 'Pin:' line )

Package: //
Pin: version /snap/
Pin-Priority: -1

I couldn't find a single mention for this except some 22 year old mailing lists and your question, so I checked APT source code and it seems that there is a condition that asks for non-empty package name, and a sole glob star won't do: apt-pkg/policy.cc @ line 452

Instead the regex works ( don't ask me why I haven't looked further! works for me though :} ).