33

The recommended way for a system wide installation of Intellij idea is to use snap. When I do that, snap updates the IDE installation which is a big problem for me because updating the development environment causes issues for me and as a developer I'd like strict control of my development environment.

If I disable snap, then I cannot even start the IDE. Google searches return nothing but meaningless long flame wars or complete suspension/disabling of snap.

Is there any way of simply telling snap not to update a piece of software while keeping all else up to date?. I'm using Ubuntu 18.04

mahonya
  • 515

5 Answers5

14

There are 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.

Pablo Bianchi
  • 15,657
Wil
  • 805
  • 2
    The refresh.hold unfortunately does not work that way. Max delay is 60 days, as stated in the documentation: "After a refresh, the next refresh can be delayed by up to 60 days, after which a refresh will be performed regardless of the refresh.hold value." – lcnittl May 27 '20 at 12:10
  • 4
    TY @lcnittl, I will amend to suggest adding the command to a cron job then. – Wil May 30 '20 at 12:33
  • 2
    Note that --devmode automatically "disable security confinement" and "--devmode implies --dangerous", too. – Mikko Rantalainen Nov 04 '21 at 14:20
12

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.
Rinzwind
  • 299,756
  • 8
    I accepted your answer since it is a definitive answer to my question but this design is ridiculous. I saw the discussion you mentioned and no one seems to consider the case where the user may want absolute control of updates. Especially for development environment components it is common for same set of tools to be used for years as per company policy etc. I guess I'll have to stop using snap for intellij idea and leave with the inconvenience in exchange for control. – mahonya Apr 04 '19 at 15:34
  • 2
    you are not alone there. a solution where you use a hammer to kill a fly: create a firewall rule to block the update of snaps. – Rinzwind Apr 04 '19 at 17:27
  • ah, that's a very interesting idea, can I block an update for individual snaps? Being lazy here, I don't know how snap works, but if it does not use a single public repo like most package managers, I may have a chance. – mahonya Apr 04 '19 at 17:37
  • thanks, I'll try to do some searching as well. – mahonya Apr 04 '19 at 17:48
  • This (the employing a hammer to kill a fly, firewall-based approach) may make https://snapcraft.io/ an unacceptable solution for my team. We prefer stable platforms. Upgraded packages tend to break things. Why did snapcraft.io not consider this? – Johnny Utahh Aug 19 '20 at 18:30
  • snaps are IOT. The idea of that concept is to take updates out of the scope of a user so it is by design that we can not influence updates. – Rinzwind Aug 19 '20 at 18:55
7

with the latest version of snap (so far on edge channel) you can disable snap updates

The new hold feature allows system administrators and end users to stop or postpone their snap updates for as long as necessary. The hold can be applied to individual snaps or the entire set of installed snaps, for a limited period of time, or – if necessary – indefinitely.

For instance, to pause snap updates for VLC for 3 days, you would run the following command:

snap refresh --hold=72h vlc

General refreshes of "vlc" held until 2022-11-17T12:04:59Z

Similarly, to pause snap refreshes for all snaps for a period of 48 hours:

snap refresh --hold=48h

Auto-refresh of all snaps held until 2022-11-16T12:27:25Z

To stop the automatic refresh completely, and without a timer:

snap refresh --hold

Auto-refresh of all snaps held indefinitely.

Source: https://snapcraft.io/blog/hold-your-horses-i-mean-snaps-new-feature-lets-you-stop-snap-updates-for-as-long-as-you-need

  • 2
    Wow, after reading 300 pages of condescending posts from the developers about how this would never be done...it was done. Maybe I'll be able to stick with Ubuntu after all. – Organic Marble Nov 17 '22 at 14:54
  • 1
    Auto-refresh of all snaps held indefinitely -> I have never seen a sweeter thing on my prompt. – RickyA Jan 12 '23 at 19:00
2

Necromancing.
There's no option for a single snap, only for all snaps.

A) You can set snap to not refresh on metered-connections

sudo snap set system refresh.metered=hold

B) You can tell snap to only update at specific times

sudo snap set system refresh.timer=sat,23:00~23:59,,sun,23:00~23:59
snap refresh --time

for syntax, see syntax documentation on snapcraft.io.

C) You can set a bogus-proxy for snapd:

snap set system proxy.http="http://127.0.0.1:1111"
snap set system proxy.https="http://127.0.0.1:1111"

D) You can block snapcraft on the firewall

iptables -F
iptables -A OUTPUT -d api.snapcraft.io -j DROP
iptables-save

iptables syntax

E) You can disable snap-refresh by setting the next refresh far into the future

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

To update snap manually

sudo snap refresh

To just list what snaps will be updated:

sudo snap refresh --list

To get info on a specific package, e.g. Chromium:

sudo snap info chromium

And to undo a hold:

sudo snap set system refresh.hold="$(date --date='today-30 days' +%Y-%m-%dT%H:%M:%S%:z)"

To just hold updates until a presentation is done (e.g. update only 30 days)

sudo snap set system refresh.hold="$(date --date='today+30 days' +%Y-%m-%dT%H:%M:%S%:z)"


Note:

The maximum number of days you can hold updates for is 60.
WitchCraft
  • 1,834
1

Nobody has mentioned adding the command to crontab, it does nothing if the snap hasn't be updated, so in my case

I use

@reboot      snap revert chromium --revision 1816

Where 1816 is the specific revision number I need.

muru
  • 197,895
  • 55
  • 485
  • 740