Snap vs Snapd in version output

When I run snap version, I get the following output:

snap    2.43.2
snapd   unknown
series  16
ubuntu  19.10
kernel  5.3.0-1015-raspi2

What’s the difference between the first and second lines? Note that snapd has version unknown,
but that’s because I built my own Snapd. It usually has the same version string as Snap. In the
Snapd code, "unknown" is apparently the default value that should get overwritten by the
mkversion.sh script.

I thought that Snap was the version of the core. However, how does it choose between the core
and core18 versions? The traditional core has a matching version string ( ), but the core version looks more like a date (20200124).

I need to know because a Snap requires some interface support that arrived in one version of Snap. I need to know where to check for the version I’m looking for. Refreshing the core works for my purposes, but I’m confused because the Snap uses core18.

Also, does the series mean that it’s using core? Do I need to do something to get it to use core18 or is this fine?

The first is the version number of the /usr/bin/snap command line tool (or the copy in the core snap if it re-execs). The second is the version of the snapd daemon the command line tool communicates with.

As you’ve guessed, you need to call mkversion.sh before building snapd to get a version number other than “unknown”. So your snap version output indicates that you are using the standard /usr/bin/snap to talk to your custom hand built snapd.

I see. So with respect to my need for interface support, which is the version number I should watch out for?

The snapd version, as snapd is the thing that creates interfaces, the snap tool is just a user-facing tool that talks to snapd to do “the real work”.

The core snap is special in that it is both a Ubuntu 16.04 root filesystem base snap and contains the snapd daemon, but the core18 snap is just an Ubuntu 18.04 root filesystem base snap. On systems like Ubuntu Core 18 where you may not have the core snap as a base, then snapd is provided by the snapd snap.

This is fine. series is this out-dated property to allow a complete rearchitecture of snaps and it wasn’t clear at the time if that was necessary for the next release, so it was set to 16, but ended up not needing to change it for Ubuntu Core 18. It has always been 16 (as long as I have known at least) and it will always be 16 (until we need to completely re-architect things of course).

Let’s say that I don’t have the core installed and just have core18 (I was able to do that using the normal Snapd, not my customized Snapd). Let’s say that I also don’t have the Snapd snap.
How do I update the daemon if core18 doesn’t include the daemon?

I assume that snapd (the entire package and command-line installed through apt install snapd)
comes with a “built-in” daemon. Would I have to install the snapd snap to “shadow” the “built-in” daemon?

I’m not sure how you can have any snaps installed if you don’t have either the core snap or the snapd snap?

Snapd the daemon is a bit unique in that on some distros including all Ubuntu and Debian like distros, the daemon will re-exec from the distro package into the snap version of snapd. This allows snapd to be updated without pushing updates to the distro package.

Due to this, it is possible that you have “snapd” installed as a distro package through apt, but if you use that snapd daemon to actually install any snaps, you will automatically get either snapd as a snap or the core snap installed (this depends on how new the snapd in the distro package is).

Oh, you’re right. When we install our core18-dependent snap, the core18 and snapd snaps are installed as well.

Ok, so it’s fair to say that Snapd will always be installed somehow, either by being included in the core snap, being installed as a snap itself, or as a distro package.

However, let’s say that I have multiple of these daemon instances installed. Let’s say that I have the core and snapd snaps installed. Which daemon will shadow the other? Would it make a difference if one of these is more up-to-date than the other? I would assume and hope that there can only be one
daemon active at a time since the output of snap version only has one entry for snapd.

Sorry for all the questions, but we need to know what environment our customers should have to guarantee interface support.

Yes you will only ever have 1 snapd daemon and the version number of that will be in snap version.

It’s a bit tricky and comes down to the re-exec logic. Firstly, there is an environment variable that some distros set that disables re-exec entirely, in which case snapd the daemon will always run from the distro packaging (but you will still have the core or core18 base snaps to use as a root filesystem for any app snaps you install). You can also manually set this if you like, but it’s not recommended, as it means you get snapd the daemon updates more slowly. If this variable is not set, then if you are on an Ubuntu or Debian-like distro, re-exec is enabled and snapd the daemon from the distro package will re-exec into either the snapd or the core snap. Which one it will re-exec into depends on:

  1. if only one or the other is installed, if you only have one of them installed it will use that
  2. how new your snapd version is, older snapd versions from distro packages will not be able to re-exec into the snapd snap and as such will use the core snap
  3. if both are installed, then whichever snap was originally installed first (the logic isn’t quite this simple but I think is practically close enough)

Finally, if you are on a system with snapd re-exec’ing into the core snap, you can manually force a transition to the snapd snap by setting snap set system experimental.snapd-snap=true, which will install the snapd snap and switch to using that instead of the core snap.

I hope this helps.

1 Like