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 five supported bases:
core22: the newest base, built from Ubuntu 22.04 LTS.
core20: built from Ubuntu 20.04 LTS.
core18: the previous standard base for snap building, based on Ubuntu 18.04 LTS.
core: based on Ubuntu 16.04 ESM, not to be confused with
bare: an empty base that’s useful with fully statically linked snaps and when testing.
Older releases of
core were occasionally referred to as core 16, but
core16 are now two distinct packages.
In most Ubuntu bases (except
core), snapd and its associated tools are provided by their relevant snaps.
core16 should no longer be used. With no current stable release, its beta and candidate releases are classed as experimental, and packages previously using it should be moved to a more recent base.
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
core18, use the following:
core22, use the following
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.
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
core22 is the currently recommended base for the majority of snaps. 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 and which plugins or extensions a base supports. If there are specific dependencies that cannot be easily met with
core20 is a valid and supported alternative, as is the older
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.
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