How to Download Snap App Updates in the Background

snap

I'm running Ubuntu 23.04 and the Snap version of Firefox. While Firefox is open, I see this notification:

Pending update of "firefox" ... Close the app to update now (9 days left)

I would like the download of the Snap Firefox update to be downloaded in the background, even before I close Firefox. Is there a way I can do something like this?

sudo snap refresh --download-only

Then, when I'm ready, I could close the Firefox app and install its update much quicker by using the pre-downloaded update.

If I run snap refresh before closing Firefox, this is what I see:

$ sudo snap refresh 
All snaps up to date.

Only once I close Firefox can I start the download:

$ sudo snap refresh
Download snap "firefox" (3206) from channel "latest/stable"

How can I download the update for Firefox (or any other Snap package) in the background, without having to close the app? I understand why the app might need to be closed for the update to be installed, but I don't understand why the app needs to be closed, even for the download itself. I'm on a slow Internet connection, and I use Firefox all the time, so it's not a pleasant experience to keep Firefox closed while the download is in progress.

Best Answer

Snap should already support what you are looking for. snapd version 2.59 mentioned this feature in its changelog:

[New feature:] Pre-download of snaps ready for refresh and automatic refresh of the snap when all apps are closed

So updates are meant to be downloaded in the background, even while the app is running.

You can check what version of snapd you have installed by running:

apt-cache policy snapd | grep Installed

You are experiencing a couple of bugs, which hopefully will be fixed in the future. Here are their bug reports:

See also this forum thread. Thank you hvbakel for pointing me to these bug reports and forum threads.

In the meantime, while you are waiting for the bugs to be fixed, you can mark yourself as affected in the bug reports, and you can close your applications before running sudo snap refresh .

Related Question