Base snaps

A base snap is a special kind of snap that provides a run-time environment with a minimal set of libraries that are common to most applications. They’re transparent to users, but they need to be considered and specified when building a snap.

Supported base snaps

There are currently four supported bases:

Older releases of core were occasionally referred to as core 16, but core and core16 are now two distinct packages.

core16 development has been dropped. With no current stable release, its beta and candidate releases are classed as experimental. As with core18 (and distinct from core), it’s built without bundling snapd and its associated tools. In both core16, core18 and core20, these are instead provided by their associated snaps.

Defining a base

Bases are defined by adding the base: keyword to a snap’s snapcraft.yaml followed by the base name.

For example, to specify core 18, use the following:

base: core18

To specify core20, use the following

base: core20

Snapcraft no longer supports building snaps with the older core base. Snapcraft 4 needs to be used instead. Snapcraft 4 is still being supported and can be installed from Snapcraft’s 4.x track:

$ snap install snapcraft --channel 4.x

For snaps using core, we highly recommend reading Snapcraft and Extended Security Maintenance for essential support details.

The base snap mounts itself as the root filesystem within your snap such that when your application runs, the base’s library paths are searched directly after the paths for your specific snap.

Warning: Compatibility mode and ESM Support When building a snap with no specified base, Snapcraft will operate in compatibility mode. This is essentially a prior (2.43-era) version of Snapcraft and, consequently, snapcraft will lose the functionality of newer releases. See Features incompatible with bases for details. This compatibility mode is no longer supported in Snapcraft 5.0. Snapcraft 4 can be installed from the 4.x track on the Snap Store (snap install snapcraft --channel 4.x). See Snapcraft and Extended Security Maintenance for essential support details.

Choosing a base

core18 is the currently recommended base for the majority of snaps. It’s synonymous with the previous Long Term Support release of Ubuntu, Ubuntu 18.04 LTS, and it’s what the snapcraft init command includes when generating a new project’s template snapcraft.yaml.

But much like choosing a distribution base for a project or server, the best base for an application is dependent on an application’s requirements. If there are specific dependencies that cannot be easily met with core18 then core20 is a valid and supported alternative.

Snapcraft extensions are a great way to easily bundle a set of common requirements into a snap, such as for running KDE Plasma or GNOME applications, but you need to select a base that’s supported by the extension you require. See Supported extensions for a list of which extensions support which bases.

Base support was added with the release of Snapcraft 3. As noted above, snaps created before this, and snaps not using the base: keyword, can still be built but they cannot use specific new features. Instead, snaps built without bases inherit attributes from their respective build environments.

Snaps that don’t use bases can often migrate to one without too much difficulty. See Upgrading snapcraft for more details on potential differences.

Building a base snap

While it is possible to build your own base snap, its publisher needs to take responsibility for its maintenance and updates. In particular:

  • bases need to be built from stable packages
  • ABI compatibility cannot broken (ie. never replace symbols or libraries, and be strict)
  • security updates must be pro-active

Base snaps can be either bootable or non-bootable. The former needs to include systemd while the latter can be leaner.

build-base

The base keyword on its own does not not take into account the creation of bases. Instead, with older versions of snapcraft, the name keyword was arbitrarily used to determine the build environment:

name: core18
type: base
# base: is not set elsewhere 

The above example uses name to specify the creation of an Ubuntu 18.04 (core18) based build environment.

But the above fails if a base has yet to be bootstrapped, or is otherwise unavailable. For example, the following will currently generate a `launch failed: Unable to find an image matching “futurecore” error:

name: futurecore
type: base
# base: is not set elsewhere 

In cases like the above, where the base has not yet been bootstrapped, the build-base keyword should be used to explicitly define the base to use for the build environment.

To solve the above issue, for example, use the following:

name: futurecore
type: base
build-base: core18
# base: is not set elsewhere 
1 Like
Upgrading snapcraft
Supported plugins
Snapcraft and Extended Security Maintenance
Snapcraft top-level metadata
Snapcraft.yaml reference
The gulp plugin
Create your own Ubuntu Core 20 image
Release notes: Snapcraft 4.2
The flutter extension
Flutter applications
The flutter plugin
The gnome-3-38 extension
The gnome-3-34 extension
Ruby applications
The plainbox-provider plugin
The colcon plugin
The catkin-tools plugin
The catkin plugin
The ament plugin
The kernel plugin
The kbuild plugin
The waf plugin
The scons plugin
The qmake plugin
The ruby plugin
The dotnet plugin
The crystal plugin
The conda plugin
The maven plugin
The godeps plugin
The Gradle plugin
The ant plugin
The python plugin
The npm plugin
The nodejs plugin
The make plugin
The cmake plugin
The autotools plugin
The go plugin
The qmake plugin
Node apps
Java applications
Go applications
Python apps
Python apps
The docs roadmap
Glossary
Migrating between bases
Release notes: Snapcraft 4.6
Release notes: Snapcraft 5.0
Snap documentation
Snapcraft build, debug and publishing docs roadmap (page breakdown)
List and table presentation ideas
Release notes: Snapcraft 3.0
Snap layouts
The meson plugin
Using parts
Adding global metadata
Creating snapcraft.yaml
Creating docker images for snapcraft
Build on Docker
Release notes: Snapcraft 3.8
Build from GitHub
Refresh control
Customising UC20 kernel command line arguments
Release notes: Snapcraft 6.0
Custom certificate support
Iterating over a build
Troubleshooting
Build and staging dependencies
Getting started
The rust plugin
Supported extensions
What's new
Create your own Ubuntu Core 18 image

Should this be 2.43-era ?

1 Like

thanks! I’ll update the version in the doc.

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!