How can I disable automatic update for a single snap in Ubuntu?

You can not. The only thing you can do is delay the update.

From the manual:

Automatic refresh

By design, non-devmode snaps installed from the store are automatically updated on a regular cadence. By default, the snapd daemon checks for updates 4 times each day.

Controlling refresh frequency

Sometimes the user wishes to have snaps refresh at known times, rather than the default. This can be achieved with the snap set system refresh.timer command. The user can specify a range of days or times when they’d prefer refreshes to occur. The following example sets the snapd daemon to refresh snaps only between 4AM and 7AM and between 7PM and 10:10PM.

snap set system refresh.timer=4:00-7:00,19:00-22:10

In theory you could alter the refresh frequency ever day where you keep moving the update moment into the future but this will not work. The snap will get updated at some point (and just ignore your refresh frequency).

See this discussion and the topics from niemeyer.

In that same link post #9 from mwinter (2017) would suggest 2 things:

Me (personally) could do this. But then I rather dislike doing any [additional] filtering on a router as this could cause issues in the future… It also blocks other snap’s and potential more (not sure what all would be at the same location) Another (in my opinion simpler) solution is to download the snap and install it locally - not from store.

  1. block using a firewall rule. That would kill all snap updates. Not a single one.
  2. remove the snap installed from the store and use a locally installed one.

There's two options:

Option 1: --devmode

Although All snaps are updated regularly, snaps installed with --devmode won't be updated because that would potentially obliterate the changes you're ostensibly working on in the snap.

For example, if you'd like to install Package and keep running the same version for the duration of a project that you and your team are working on, thereby removing any risk of regressions like broken plugins, then use these commands:

snap install package
snap list package
snap refresh --devmode --channel 2019.3/stable package

The first gets it into your system. The second lists the available versions. The third sets it to the specific version you want, and enables --devmode so that it will not get automatically refreshed.

Option 2: refresh.hold

You can also configure snap to hold refresh activity until a specific date:

sudo snap set system refresh.hold="2030-01-01T01:00:00-01:00"

and then also:

sudo crontab -e

and add the following:

# prevent snap updates entirely:
1 1 1 * * /usr/bin/snap set system refresh.hold="2030-01-01T01:00:00-01:00"  

This would prevent automated snap updates until the start of 2030 GMT

The plus to this method is that you can use confinement. The drawback is that you need to refresh all your snaps manually.

Tags:

Snap