Updates – How to Stop an Individual Snap from Updating in Ubuntu 22.04 LTS

22.04firefoxsnapupdates

Is there a mechanism for stopping an individual Snap from updating?

Context

There is an ongoing issue with Firefox snap and have decided to replace the snap version with the deb version using the instructions contained in this FOSTips post in so far as it related to Ubuntu 22.04 LTS.

The Issue

After following the instructions (with the exception that the "Set PPA Priority" fails since the file mentioned does not exist in 22.04) I noted that, following an update, the Snap version of Firefox was restored to the system and the issue I was having returned accordingly.

The issue concerns an incorrect rendering of the web page from the Dropbox drop down menu. This issue was resolved by installing the deb version of Firefox. It is not clear whether it is an issue with Dropbox (less likely) or the snap version of `Firefox (most likely).

Other Research

I have considered the options set out in this Q&A from AU but these solutions do not mention preventing the automatic re-installation of a package as part of the update process behind the scenes, just in the main a delaying process.

Since I wish to entirely disable updates to this snap (but allow other snaps which perform well to be updated) in isolation is there a specific set of workable commands available to achieve this?

Best Answer

To your general question, "How to stop an individual snap from updating Ubuntu 22.04 LTS", the answer is, as you also found out: you can't. There is little user control on snap updates - they update automatically and that cannot be stopped. That is one of the criticism about snap.

To your specific question with respect to Firefox snap being installed on an update, it is actually the firefox APT package of Ubuntu that is being updated. That package triggers an install of the snap version. There are many tutorials out nowadays on how to replace the snap version by a .deb version from a third party repository.

For updates of APT packages, there is a lot more control. The installation of the Ubuntu version of firefox specifically could be prohibited with following APT preference:

cat <<EOF | sudo tee /etc/apt/preferences.d/firefox-no-snap.pref
Package: firefox*
Pin: release o=Ubuntu*
Pin-Priority: -1
EOF

This creates a configuration file /etc/apt/preferences.d/firefox-no-snap.pref that instructs APT to forbid installing the firefox .deb package of the default Ubuntu repositories. Thus, the snap version of firefox only can be installed manually by the snap install firefox command. A firefox package from another source could still be installed.

There are many tutorials to be found on how to replace the snap Firefox by a deb version. All involve configuration changes to APT, either by promoting the priority of firefox from a third party PPA, or demoting the priority of the default Ubuntu package.

Related Question