Base snaps

While this statement may once have been true:

core16 is a thing, and it’s very much not the same as core (as per How to use core16 as base snap? et cetera)

Perhaps some language like:

and later

would help here?

Thanks for flagging this. I’ve attempted to update the text to make this important distinction clearer.

1 Like

This is great, but could you include some suggestions on choosing a base please? For example suppose these are true:

  • I have a snap that doesn’t currently specify a base and feel like I should add one. Should I choose core, core16, or core18? What difference will it make to my users, and are there any points I need to consider - presumably setting core18 means that the packages in the background change compared to the current snap.

  • I am writing a new snap, what base should I use? What situation might I use core instead of core18?

It feels like the answer is probably “use core18 unless you have reason not to”, but it’s not clear, and effectively changing the OS underneath my application feels like a big update.

1 Like

Thanks for your suggestions. I’ve added a new section on Choosing a base to try and broadly answer what must be a common question, though we can probably do a better job of explaining where core, core16 and core18 (and shortly, core20) fit into the snap ecosystem. I’ll come back to it.

1 Like

Have just build the core20 snap from https://github.com/snapcore/core20.

Then i found a packer, to build a multipass image. https://discourse.ubuntu.com/t/building-multipass-images-with-packer/12361

Now i searching the source, to build the core20 image for multipass…

Could we add a snippet here that explains that if a snap does not declare a base it will use core as it’s base implicitly?

Yep, of course. I’ll add this - thanks!

1 Like

To build a snap based on core20 before Ubuntu 20.04 is released, you can build with snapcraft --destructive-mode inside a daily build of Ubuntu 20.04. For example with lxd you would run:

lxc launch ubuntu-daily:20.04 -c focal
lxc shell focal 
$ snapcraft --destructive-mode # builds your `base: core20` snap

@degville even at the time this doc was written, despite snapcraft error messages, core20 was already bootstrapped and available from stable channel and used by launchpad for staging core20 builds of gadgets / kernels etc.

In the spiriti of making the document timeless, I have changed the examples to attempt to build a “futurecore” whilst using an existing core18 as a build-base.

1 Like

Focal based multipass images already exist, in the daily stream, not release stream.

I don’t know however, how to make multipass / snapcraft use daily stream of focal images.

  1. I have patched snapcraft like this:
    https://github.com/sd-hd/snapcraft/commit/6a928fc5341c75566f30d716d4c3060ff73d5eed#diff-4e5027ec49fe1b99fc6f5674421fb832
  2. Then i build core20 snap from here: https://github.com/snapcore/core20
  3. Put the core20 into my snap directory
  4. Set base to core20 and build-base to core18 like here: https://github.com/sd-hd/termite-snap/blob/master/snap/snapcraft.yaml

Then the build with lxd works. https://github.com/sd-hd/termite-snap/actions/runs/39837558/workflow

But not sure, if there is something more to be done, if you use multipass

While there is considerable discussion about using a base of “core”, this page clearly says:

“Building a snap with core is no longer supported in Snapcraft 5.0.”

But in downloading snaps to examine their YAML files, I did:

$ snap download tree

as a simple example, and its snapcraft.yaml file contains the line:

base: core

So I’m confused. BTW, this is all on the daily build of 22.04.

Thanks for commenting on this. core was the default base before core18 and core20 were developed. As a result, many snaps were originally built using core and may still be using it. The tree snap is a good example as it hasn’t been updated since 2019.

core is based on Ubuntu 16.04 LTS which is now supported only via Extended Support Maintenance (see Snapcraft and Extended Security Maintenance). Consequently, core was dropped from the main development branch of Snapcraft as Snapcraft’s architecture and plugin system changed.

Snapcraft 4.x remains compatible with core and will be updated and maintained on its own track for the duration of the the ESM period of Ubuntu 16.04 LTS.

I’ve attempted to update the document to make this clearer.

" core20, built from the latest LTS release … cannot currently be used with Snapcraft extensions …"

Really? I’m pretty sure they can. Is this claim out of date?

Yep. You’re right. I’ve updated this to link to our Supported extensions page. Thanks!

This paragraph might need a bit of an update, minimally to remove the terminology ‘both’ before listing 3 core versions, but possibly also to de-emphasise core16 since its use has been discouraged for several years.

Perhaps something like:

The first paragraph under “Choosing a base” still recommends core18, but under “Supported base snaps” it recommends core20.

The joys of updating documentation for new releases :slight_smile:

Thanks so much for raising these issues. I’ve edited the document and also included your earlier suggested paragraph.

1 Like

At what point can we drop the recommendation to keep using core20 until core22 is adequately fully-featured?

Thanks for mentioning this. I think that point is now (I’ve edited it) and we should probably carefully word such admonitions in the future so we don’t have to go back through our docs and edit things.