I know that I can update a snap package using
sudo snap refresh <package>
But is there a way to update all snaps, like
sudo apt dist-upgrade
sudo snap refresh
Will do this. It is part of snapd
2.0.8, which landed 2016-06-13 in xenial-updates
.
snap refresh --list
Only lists the updates without refreshing the packages.
snap info <snap name>
Can show which versions are available for a particular package.
You can also update a specific application if the other method fails
sudo snap refresh <Application>
Example usage:
sudo snap refresh slack --classic
sudo snap refresh
snap
prompts you for your password if you don't include sudo
so it's not entirely necessary.
Commented
Nov 7, 2019 at 22:53
snapd
2.43.3 and it doesn't prompt me, it just says error: access denied (try with sudo)
.
According to Snap tutorial Snaps are automatically updated in the background once per day.
However, if you don't close the application it will not be updated and you will receive daily notifications to do so.
snap refresh firefox
was the only way to get the latest security patches.
Generally, you don't need to do anything.
snapd, in Ubuntu installs, will automatically check for updates several times each day. That's a key feature of snaps.
Here's how to determine how often snapd will automatically check for updates: (source)
$ snap refresh --time
timer: 00:00~24:00/4 <------ "/4" means refresh every 4 hours.
last: today at 17:15 CDT
next: today at 21:45 CDT
next
is seven days ago. Should I be bothered? My timer is the same as yours, but in the source link there is the info refresh 4 times a day, which is every 6 hours.So if my Pc is never on for 6 hours, I will never get an update. So I have to change the config..
For me the issue was with snap store. It booted on start hence it could never update itself.
so I ran to verify that snap-store is the issue
sudo snap refresh
snap refresh --list
snap refresh --time
The fix was to kill the process and then update:
sudo killall snap-store
sudo snap refresh
Try this in /usr/bin/update-snaps
:
#!/bin/bash
ROOT_UID="0"
#Check if run as root
if [ "$UID" -ne "$ROOT_UID" ] ; then
echo "You must be root to do that!"
exit 1
fi
snap list | awk -F" " '{if ($1 && NR>1) { system("snap refresh " $1 " 2>/dev/null") }}'
If what we want is to check if there is an update of an app and install it, the command will be the following, where APPLICATION corresponds to the program we want to update:
sudo snap refresh APPLICATION
For example, if we want update Firefox, the command would be sudo snap refresh firefox
.
What I and maybe some of you are wondering is: "Who updates only one package from the terminal?" Surely someone will, but I usually update everything. The Snap equivalent of sudo apt update && sudo apt upgrade
, Is the following:
By not indicating any package, what it will do is search for all the Snaps that we have installed, it will check if there is a new version and it will install it.
The third command I was talking about may be interesting if you only want to install some packages. It would be the following:
This can help us, for example, if we are waiting for an update like May water, we see that it is and then we want to install the app we expected and some other, avoiding installing everything if it turns out that there is a lot to install. In this way, we would save time. In this article you have other options that we can use with the «snap» command.
An alternative way that worked for me was to go to the search bar and search for snap store, open that up, go to the update tab, then press update.
With Slack (and some other apps) it's a little more tricky because they run in the background and start automatically on reboot. Be sure to close the app in the background and ensure that it has not started automatically on reboot if you wish to update. Here's a command to stop slack as an example of such a program:
sudo kill -9 $(pidof slack)
After that you can run the update of the specific app:
sudo snap refresh slack --classic
to have it take effect.
Here's a handy copy and paste one-liner:
sudo kill -9 $(pidof slack);sudo snap refresh slack --classic
Might even put that in a shutdown script to fully automate.