353

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
0

9 Answers 9

499
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
9
  • 1
    You need to do sudo snap refresh Apr 25, 2019 at 4:03
  • 10
    @Boris, snap prompts you for your password if you don't include sudo so it's not entirely necessary. Nov 7, 2019 at 22:53
  • 1
    @SpookyGengar no it doesn't: $ snap refresh error: access denied (try with sudo) Nov 26, 2019 at 21:29
  • 3
    @RickyNelson On my 18.04 it does prompt me without using sudo
    – John
    Jan 10, 2020 at 2:18
  • 1
    @SpookyGengar @John I'm on Ubuntu 19.10 with snapd 2.43.3 and it doesn't prompt me, it just says error: access denied (try with sudo). Feb 25, 2020 at 22:25
65

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.

3
  • However, I was checking Firefox today which said "Updates disabled by your system administrator" (strange since I am the only user and I just installed my OS three days ago). snap refresh firefox was the only way to get the latest security patches.
    – John
    Jan 10, 2020 at 2:20
  • Interesting. Please add a comment if you ever find out why that's the case...
    – chrisvdb
    Jan 10, 2020 at 3:11
  • 2
    However, if you don't close the application it will not be updated and you will receive daily notifications to do so.
    – thanos.a
    Jun 1 at 14:08
22

Generally, you don't need to do anything.

snapd, in Ubuntu installs, will automatically check for updates. 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
2
  • My 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..
    – Timo
    Oct 17, 2020 at 20:06
  • 1
    @Timo please open a new question if your issue persists. We're not going to diagnose that underlying cause of your symptom here.
    – user535733
    Oct 24, 2020 at 10:17
10

Try running snap with sudo:

sudo snap refresh
0
5

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") }}'
1
  • 6
    This is not necessary any more.
    – dholbach
    Jun 14, 2016 at 7:11
1

Updates the Snap packages

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.

List updates without installing them

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.

1

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.

0

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.

0

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 
New contributor
Snake_py is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.