Disable automatic snap updates

Foreword

I have Signal installed as a desktop app via Snap Store. One day I noticed it started to fail to sync messages from my phone and next day it spit out an error message and quit. It turned out snap had updated the app in the backgroud, but the app does not handle automated updates gracefully. Also, Signal team doesn’t officially support snap packages.

Snap default behaviour

There is an interesting conversation from many years ago where Snap developers explained their stance and reasoning for it. In short, snap does automated updates in the background and there is no intention to allow user to simply disable the updates. This is because snap specifically intents to address issues which arise when user does not actively update their installed applications.

I think Snap developers – and by extension Microsoft for that matter – have the right approach. Updating applications without user invention reduces the number of exploitable security issues in the wild. Additionally, I find it useful, if application developers feel pressure to create their applications in a way that they continue working even when updated silently in the background.

But if you are having update issues with snap packaged software, keep on reading.

Delay backgroud updates

Snap has a configuration variable refresh.hold which delays the next automatic update until specified time. Variable value uses RFC3339. To get an example timestamp with correct format, use date(1) utility:

$ date --iso-8601=sec
2021-01-01T00:00:00+00:00

You can try to effectively disable snap background updates by delaying the next update as many years into the future as you see fit. This needs to be done as root:

# snap set system refresh.hold=$(date -d 4years --iso-8601=sec)

Unfortunately that does not work as expected, because snap only allows to delay the next refresh at most 60 days, after which a refresh will be performed regardless of the refresh.hold value:

$ snap refresh --time
timer: 00:00~24:00/4
last: yesterday at 01:23 UTC
hold: in 59 days, at 01:23 UTC
next: yesterday at 01:23 UTC (but held)

With this method you can avoid daily background updates and delay updating for a couple of mounths. But keep on reading if your use case needs a more permanent solution.

Disable backgroud updates

You can block snap updates (and all snap network activity for that matter) by not allowing snap to access the Snap Store: Just add following line to your /etc/hosts file:

127.0.0.1 api.snapcraft.io

For more ideas on how to control the update behaviour of snap, see this askubuntu question and related answer.