Is it possible to disable autorefresh in snap? This link says that Snaps are updated automatically in the background to the latest version, every day. Some snaps (e.g. vlc) are built daily, and it makes no sense to install them every day.
9 Answers
There are a couple of options, depending on what you want exactly.
An update broke my application!
Run snap revert package-name
to go back to the previous version of that application. You will stay on that version until the next version of the app gets released. If the next version is broken too, you can run snap revert
again.
I want to stick with an older version of the app
Many software in the snap store uses tracks for major software releases. Most snaps default to using the latest/stable
track, which will give you the latest updates of the application once they are released but users can choose a different track to stick with a specific version.
For the CLion IDE, for example, you can see the supported tracks by running snap info clion
. You can switch to a different track by running snap refresh clion --channel=2020.2/stable
. You will stay on that track until you manually change to a different track. You will still get automatic updates for the application but depending on which track you choose, you will only get the minor updates for that specific version of the software.
Publishers decide whether or not to enable tracks in their snap, so if a snap you like doesn't have a track for the version you need, be sure to contact the publisher!
I want to hold all updates until after my big presentation
The "hold" option is what you need. You specify an exact date and snap will hold any updates until that date. For example, this holds updates for the next 30 days.
snap refresh --hold=<duration> <snap1> <snap2>
- If you specify no snaps, it will apply to the entire system
- Use
--hold=forever
if you want to disable updates indefinitely.
I don't want it to update during the weekdays
In this case, you probably want to change the refresh timer. For example, the following option sets the refresh timer to the last Saturday of the month, from 23:00 to 1:00 the next day.
sudo snap set system refresh.timer=sat5,23:00-01:00
You can use the CLI tools or the snap store to see which updates are available.
I want to disable updates when I'm paying for my download bandwidth
By default, snap will not update when NetworkManager detects a metered connection such as an LTE/3G/4G. If NetworkManager does not detect it correctly, you can set it manually.
I want to disable updates while the application is running.
This is an experimental feature you can turn on by running the following command:
snap set core experimental.refresh-app-awareness=true
For more info, see snap refresh awareness and update inhibition
I want to do something else!
See the Controlling updates docs for more options.
-
5I want to prohibit automatic updates while I am using the program which is being updated. To my experience, apps usually crash when they are updated while running (e.g. Chrome).– w-skyMar 4, 2021 at 10:02
-
3Good suggestion @w-sky! You can do this by turning on the experimental "refresh app awareness" option: snapcraft.io/blog/… I updated the answer to include this info. Mar 5, 2021 at 9:16
It is at the time of this writing not possible (officially), which has stirred quite a debate. Better ways to control updates on the desktop are still being discussed.
Solution 1
Block the store in your /etc/hosts/
file:
127.0.0.1 api.snapcraft.io
For me what worked was sudo nano /etc/hosts
, copy-pasted the line, then I hit F2, then Y, then ENTER.
Solution 2
Disable automatic updating if the network connection is metered.
First, go to your network settings.
Then, click on the cog wheels on the right side of both of your network interfaces and tick "restrict background data usage" - this marks the connection as being metered.
Finally, open a terminal and type (docs):
sudo snap set system refresh.metered=hold
-
2
refresh.metered=hold
only works when NetworkManager detects a metered connection. Oct 31, 2020 at 22:47 -
1
Stop (will restart on boot), then disable the snapd
daemon:
sudo systemctl stop snapd.service
sudo systemctl mask snapd.service
Note ( systemctl
): mask
is a stronger version of disable
.
To re-enable and refresh:
sudo systemctl unmask snapd.service
sudo systemctl start snapd.service
sudo snap refresh
refresh
will refresh all snaps in the system.
This is a summary of much better answers than any given here. For some reason ~that~ question was marked as duplicate pointing back to this one :).
-
4This is the only rationale answer. Having something like snap altering the system in an unpredictable way is not only annoying. It is destructive. Like an atomic bomb. Really. I'd rater be struck down by some rogue atomic bomb than something as badly designed as snap on purpose! Thank you very much! Your solution works.– TinoApr 30, 2021 at 16:05
-
3Unfortunately this no longer works, since some software (eg. firefox) will refuse to start if snapd is not running. Aug 1, 2022 at 9:56
-
with the latest version of snap (2.58+) 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.
-
It's not working in Ubuntu 22.04, I'm getting
error: unknown flag hold
.– DanielDec 21, 2022 at 15:20 -
-
I'm not using edge. That might be the issue since this feature came out in snap 2.58 and my version is 2.57 (askubuntu.com/questions/1446618/in-snap-error-unknown-flag-hold).– DanielDec 24, 2022 at 11:39
-
1Should work as of snap 2.58 : forum.snapcraft.io/t/… Can confirm working in 2.59 on 22.04 Jul 30, 2023 at 12:58
-
1
The refresh service is launched by systemd and configured in:
- /lib/systemd/system/snapd.refresh.service
- /lib/systemd/system/snapd.refresh.timer
If you want to disable the autorefresh, override those configurations in /etc/systemd. Probaby the easiest way is to just set the timer to the frequency you like.
It's currently not possible to do so. However, you can schedule the time when the snaps are being automatically updated to your liking with this command:
sudo snap set core refresh.schedule=8:00-20:00
In this case, the updates will happen only once a day between 8pm and 8am (An example).
-
``` snap set core refresh.schedule=20-8 error: cannot perform the following tasks: - Run configure hook of "core" snap (run hook "configure": cannot parse "20": not a valid time) ``` Dec 21, 2017 at 16:36
-
-
Yep, this works I just set mine to
18:00-20:00
- which was outside the time that I was currently. After running ansudo snap abort 123
on the current refresh job and a system reboot I no longer had the refresh.– icc97Jul 31, 2020 at 14:26 -
1With snapd versions prior to 2.31, replace
refresh.timer
withrefresh.schedule
as per snapcraft.io/docs/keeping-snaps-up-to-date Oct 31, 2020 at 22:45
One workaround may be to install from a version specific channel, i.e. for PyCharm:
snap install pycharm-professional --channel 2018.3/stable --classic
Then the snap will not be updated unless a new patch version to 2018.3 is released.
To see the channels available, use snap info
, i.e.
$ snap info pycharm-professional
name: pycharm-professional
summary: Python IDE for Professional Developers
publisher: jetbrains✓
contact: https://www.jetbrains.com/pycharm/documentation/
license: unset
description: |
PyCharm Professional Edition is an IDE for professional Python development. It is designed by
programmers, for programmers, to provide all the tools you need for productive Python, Web and
Scientific development.
PyCharm Professional Edition is available for a free 30-day evaluation.
Monthly and yearly subscription options are available for companies and individual users. Find out
more on https://www.jetbrains.com/pycharm/buy/
commands:
- pycharm-professional
snap-id: Uqpw0ZWqy6Wh4mgaWE0rxgM5tAGCwf4D
tracking: stable
refresh-date: 10 days ago, at 09:22 PDT
channels:
stable: 2019.1.1 2019-04-03 (127) 392MB classic
candidate: 2019.1.1 2019-04-03 (127) 392MB classic
beta: 2019.1.1 2019-04-03 (127) 392MB classic
edge: 2019.1.1 2019-04-03 (127) 392MB classic
2019.1/stable: 2019.1.1 2019-04-03 (127) 392MB classic
2019.1/candidate: 2019.1.1 2019-04-03 (127) 392MB classic
2019.1/beta: 2019.1.1 2019-04-03 (127) 392MB classic
2019.1/edge: 2019.1.1 2019-04-03 (127) 392MB classic
2018.3/stable: 2018.3.5 2019-02-27 (121) 355MB classic
2018.3/candidate: 2018.3.5 2019-02-27 (121) 355MB classic
2018.3/beta: 2018.3.5 2019-02-27 (121) 355MB classic
2018.3/edge: 2018.3.5 2019-02-27 (121) 355MB classic
2018.2/stable: 2018.2.8 2019-04-12 (128) 313MB classic
2018.2/candidate: 2018.2.8 2019-04-12 (128) 313MB classic
2018.2/beta: 2018.2.8 2019-04-12 (128) 313MB classic
2018.2/edge: 2018.2.8 2019-04-12 (128) 313MB classic
2018.1/stable: 2018.1.6 2018-11-15 (101) 314MB classic
2018.1/candidate: 2018.1.6 2018-11-15 (101) 314MB classic
2018.1/beta: 2018.1.6 2018-11-15 (101) 314MB classic
2018.1/edge: 2018.1.6 2018-11-15 (101) 314MB classic
2017.3/stable: 2017.3.7 2018-11-15 (100) 344MB classic
2017.3/candidate: 2017.3.7 2018-11-15 (100) 344MB classic
2017.3/beta: 2017.3.7 2018-11-15 (100) 344MB classic
2017.3/edge: 2017.3.7 2018-11-15 (100) 344MB classic
installed: 2019.1.1 (127) 392MB classic
This is my solution to this problem (tested on Ubuntu 22.04 in June 2022). The below assumes that you wish to have control over when updates are made to your installation. That is, to review the proposed updates to be made and control the timing of those updates, but are not looking to hold back individual snaps.
Snap configuration of automatic refreshes
As detailed in other answers, snap permits control of the timing of automatic updates, but with a hard deadline of 90 days (at the time of writing) after the last refresh irrespective of any other parameters. The controls are described in this part of the documentation (https://snapcraft.io/docs/keeping-snaps-up-to-date).
Initial solution
Initially, I set the hold date to 90 days in the future, and call “snap refresh --list” to determine which snaps have available updates, followed by a “snap refresh” to complete the update. And finally, reset the hold date to 90 days into the future. But, this isn’t enough as the effective hold date saved is 90 days after the last refresh.
“last-refresh”
For whatever reason, the “last-refresh” parameter in the snapd configuration is ONLY updated when snapd executes an automatic refresh, and not a manually initiated one. Note: the code reason is that the server doesn't set last-refresh if you provide a list of snaps to refresh, and the command line client converts a full refresh command into a server request with a list containing all active (not held) snaps.
Therefore, for this scheme to actually work, you need to somehow update last-refresh. One way to do this would be to change the “hold” and “timer” parameters so that an autorefresh will occur (but nothing will need to be updated as you just did so manually), and set them back to 90 days in the future after the autorefresh.
Manually update “Last-refresh”
Less robust, not good practice, likely frowned upon by the development team, but easier to control, is to manually update it as detailed in the prevent_autorefresh function in this test file (https://github.com/snapcore/snapd/blob/master/tests/lib/tools/snapd-state). Please note: snapd doesn’t re-read the configuration file until restarted.
Procedure for performing a refresh (in script file format)
#!/bin/sh
sudo snap refresh --list
read -p "Run snap refresh [Yes/no]?" refresh
case $refresh in
[Nn]* ) break;;
* )
sudo snap refresh
#Update the last-refresh time
sudo systemctl stop snapd
sudo jq -c ".data[\"last-refresh\"] = \"$(date +%Y-%m-%dT%H:%M:%S%:z)\"" /var/lib/snapd/state.json > /var/lib/snapd/state.json.new
sudo chmod 600 /var/lib/snapd/state.json.new
sudo mv /var/lib/snapd/state.json.new /var/lib/snapd/state.json
sudo systemctl start snapd
sudo snap set system refresh.hold="$(date --date='today+90days' --iso-8601=seconds)"
;;
esac
Holding snaps beyond 90 days
From my review of the code and testing to date, I believe it is possible to hold indefinitely by regularly updating the last-refresh parameter and resetting the hold date without performing a manual refresh. I have not tested this as it is not what I want to do.
You can set up a local Snap Store Proxy to control what revisions the Snap client sees.
sudo systemctl stop snapd.service
sudo systemctl disable snapd.service
probably works. ubuntu became os-x: 'how do you want to update?right now
orauto
'sudo snap refresh --hold=forever <package names>
. Doesn't require turning off the whole snap service, throwing the baby out with the bathwater.