Feature image for the article about how to disable Snap update

How to disable automatic Snap update

Snap packages make it possible to conveniently install software applications on your Linux system. Perfect when your Linux distribution’s package manager does not offer a specific application or the right version. Application developers now only need to package their software once and publish it on the Snapcraft website. Snaps also have a disadvantage: they automatically update to a newer version in the background. This article explains how to disable this automatic Snap update feature.

Background

Think of a Snap as a software package that you can install on your Linux system in a convenient way. Note that I wrote Linux system, and not a specific Linux distribution. Snaps offer a Linux distribution agnostic method for installing software. A Snap package runs in a sandbox environment, isolated from the rest of your Linux system. When installing a Snap package, you simply snap it on to your Linux system, without negatively effecting it. As in no library or dependency conflicts. It just works.

Canonical, the developer, maintainer and publisher of the popular Ubuntu distribution, developed the packaging technology behind Snaps. They also maintain the Snapcraft website, the online Snap package repository. It’s the place to go to when looking for software packaged as a Snap.

The Ubuntu distribution supports Snaps out-of-the-box. For other Linux distributions, you just need to install the snapd package. You can find detailed installation instructions here.

Benefits of Snap packages

Linux users can benefit from Snaps, because it allows them to conveniently install software (or a specific version of software) not offered by their distribution’s online package repository. For Linux application developers, Snaps offer benefits too. They just need to package their software once as a Snap and then publish it on Snapcraft.

Disadvantages of Snap packages

Unfortunately, Snaps come with one major issue that bothers some Linux users (including myself): Snaps update automatically in the background. So without your explicit input, all of a sudden a new software version gets installed. One of the reasons I prefer Linux over other operating systems, is that it gives me full control. I decide when and what gets installed.

Especially when you run Snaps on a server, these automatic Snap updates are a deal-breaker. Server administrators run CentOS, Debian or Ubuntu LTS on a server for a reason, as opposed to a rolling release distribution. They want version stability for their server software. That server needs to run 24/7 with as little administration effort as possible. They only want security patches for software, not new versions.

Imagine running the Snap version of the LXD container manager. Then all of a sudden a new version of LXD gets automatically installed, without your consent, and potentially breaks some functionality on your containers. That’s nightmare stuff for server administrators.

Can you disable the automatic Snap update?

This leads to the question: Can you disable this automatic Snap update feature? The short answer to this question is: no. Luckily there are some workarounds available. Hence, the goal of this article is to explain these workarounds.

What do you need

Snaps work on all Linux distributions. Therefore, you just need Linux running somewhere to implement the workarounds, presented in this article. That said, I do recommend Ubuntu for this article. Simply because Ubuntu offers support for Snap packages by default. In preparation for this article, I freshly installed Ubuntu Desktop 20.04 in a VirtualBox virtual machine. The following two tutorials contain detailed instructions on setting up a similar environment:

Workaround 1: Use Flatpaks instead of Snaps

Instead of Snaps, you could consider using Flatpaks. The idea behind Flatpaks is similar to that of Snaps. Flatpaks also work on all Linux distributions and run in an isolated sandbox environment. Just like the Snapcraft website for Snaps, you can find Flatpaks on the Flathub website. In the past I dedicated an entire article to the ins-and-outs of using Flatpaks: How to install Flatpak applications from Flathub.

The following list highlights the main differences between Snaps and Flatpaks:

  • The Flatpak technology is developed and maintained by an independent community. Snaps are backed by Canonical, a corporate entity.
  • In contrast with Snaps, Flatpaks do not automatically update. You are in full control of when you update your installed Flatpaks.

Because you are in full control of when you update a Flatpak, Flatpaks offer a viable workaround for disabling the automatic Snap update feature. You just need to find out if a Flatpak packaged version is available for your software application. Point your web browser to the Flathub website to find out.

Workaround 2: Install a Snap from a specific channel

There is a large overlap between the software offerings on the Snapcraft and Flathub websites, but it’s not 100%. Because of this, it can happen that you can only install a certain software application as a Snap and not a Flatpak. The previously mentioned LXD software serves as a good example. LXD enables you to create and install software in containers. Think of it as a light-weight alternative to virtual machines. You can currently only install LXD as a Snap and not a Flatpak.

It’s common to use LXD on servers. Especially on servers, the automatic Snap update feature is typically not desired. Luckily a workaround exists: Instead of installing the latest version of a Snap, you can install the Snap from a specific channel. Think of a channel as a branch for a specific version of the software. If you install the Snap from the channel, you still get automatic updates, but only those that apply to the channel’s version. These typically contain security fixes and not feature or version changes. With other words, exactly what you want as a Linux system administrator.

Installing the LXD Snap from a specific channel

I’ll use the LXD Snap to further explain this workaround. Normally, you would head over to the Snapcraft website and locate the LXD Snap and its installation instructions:

Browser screenshot of finding the LXD Snap installation instructions on the Snapcraft website.

This sudo snap install lxd command installs the latest version and the Snap update feature will automatically install a newer version, when available. So not what we want.

We want to install from a specific channel. First, we need to find out the available channels. Open up the terminal and run this command:

  • snap info [SNAP NAME]

In the example case of LXD:

  • snap info lxd
Terminal screenshot showing the output of command "snap info lxd". It lists the available channels of the LXD Snap package.

By default, a Snap installs from the latest/stable channel. In the screenshot above, this would be LXD version 4.13. Now if you look closely, you notice that channel 4.13/stable also offers LXD version 4.13. If we install LXD from the 4.13/stable channel, it will always stay on this channel. This effectively means that you still get automatic updates for security fixes for the version you installed. However, the LXD Snap will not update to a new version. Exactly what we want.

To install a Snap from a specific channel, the following command syntax works:

  • sudo snap install --channel [CHANNEL] [SNAP NAME]

In our example for LXD verion 4.13:

  • sudo snap install --channel 4.13/stable lxd

After completion of the Snap installation, you can run the snap list command to check the version and channel of the Snap:

Terminal screenshot that shows how to install the LXD Snap package from a specific channel. This is a workaround to disable the automatic Snap update feature. This way the Snap will get updates and fixes, but will never update to a newer version.

Upgrade or downgrade the LXD Snap to a different channel

Using the presented workaround, you can change the channel that an installed Snap tracks. This means that you can decide if and when to update (or downgrade) to a different version of the Snap. The syntax for this:

  • sudo snap refresh --channel [CHANNEL] [SNAP NAME]

Sticking with the LXD Snap as an example, we can downgrade to version 4.12 by running command:

  • sudo snap refresh --channel 4.12/stable lxd

Wrap up

With Snap packages you can easily and conveniently install software on your Linux system. Especially handy when your distribution does not offer the software you want to install or not the version you want. Snaps work on all Linux distributions, making them a great option for those that enjoy distro-hopping.

The one feature about Snaps that not everyone loves, is that they automatically update in the background. This includes updates to new versions the moment the publisher releases these to the Snapcraft website. Unfortunately, you cannot completely disable this automatic Snap update feature. This article presented two workarounds for this:

  • Use a Flatpak instead of a Snap.
  • Install the Snap from a specific channel.

Personally, I combine both workarounds. So when installing a Linux system, I follow these steps:

  1. Install as much software as possible, using the Linux distribution’s package manager.
  2. Try to install the remaining software from Flathub as a Flatpak.
  3. If not available on Flathub, locate the software on Snapcraft and install the Snap from a specific channel.

PragmaticLinux

Long term Linux enthusiast, open source software developer and technical writer.

View all posts by PragmaticLinux →