3

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?

graham
  • 10,436

2 Answers2

5

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.

vanadium
  • 88,010
  • can the snap and apt versions of Firefox co-exist happily on the same system and will snap disable firefox in terminal then prevent the snap update (as a work-around)? – graham May 11 '22 at 10:00
  • 1
    See the first part of my answer. No, you cannot prevent update of an installed snap. Yes, both versions can happily coexist, but that was not scope of your current question, so it should not be in the answer. – vanadium May 11 '22 at 10:37
  • 1
    unattended upgrades revert to snap if unconfigured. See here how to prevent this. – mook765 May 11 '22 at 10:53
  • @mook765 there are different ways to Rome. The config file in my answer also will prevent installing the snap version, and it is a config file that will work with any added PPA that also contains firefox. – vanadium May 11 '22 at 10:56
  • @mook765 thanks for that link. I've done the deed and await the outcome with interest after the next scheduled unattended upgrade snap activity. – graham May 11 '22 at 13:25
  • 1
    @vanadium I really don't mind you adding your comment about co-existing versions and upgrade prevention to your answer for completeness, after which I will accept the answer. – graham May 11 '22 at 13:28
  • 1
    That is not how it works here. You ask a question, a specific answer follows. Changing the question is not allowed, comments can steer you to improve it. Feel free to open a new question: that way, users will be able to find the answer, which they will not if I hide an answer to a question not asked in the current answer. – vanadium May 11 '22 at 14:09
  • Sorry to disagree with you. This Q&A with an answer from @zanna seems to suggest otherwise on a case by case basis. I think adding another question is unnecessary since the basic tenor of this one follows the basic principles and repeating most of it would be overkill. I'll be guided as directed by site moderation. – graham May 11 '22 at 14:56
  • 1
    My policy is to try keeping focus, I answer the question that has been asked the best possible, and as specific as possible. – vanadium May 11 '22 at 16:56
0

You can stop the auto updates with (at least at the time of posting):

snap refresh --hold firefox

That will prevent it from doing updates. You can add time to it as well with --hold=24h for example.

https://ubuntuhandbook.org/index.php/2022/11/turn-off-automatic-updates-snap-apps/

quest
  • 1
  • 1
    See the answer from vanadium: no you can not prevent a snap from updating. You can postpone the moment but at some moment in time a snap will be forced to update. – Rinzwind Apr 12 '23 at 13:38
  • 1
    I disabled the firefox package with snap disable firefox. This prevents the snap package from ever being installed. However, @vanadium's solution is still required to prevent Ubuntu's transitional firefox package to remove the mozilla PPA version and then NOT to install the disabled snap package. – axtimwalde May 03 '23 at 19:47