Snapcraft 3 contains fundamental improvements to the way snaps are built.
In particular, snaps are now built within an isolated build environments that’s tuned for a desired target. This provides API and ABI compatibility for every binary built within the environment, and ensures a build isn’t affected by outside dependencies and system configuration.
Build environments work by leveraging base snaps. A base snap offers a run-time environment with a minimal set of libraries that are common to most applications. At build time, the snapcraft tool ensures you are creating a snap inside an environment specifically tailored for its base.
During normal operation, the build environment is isolated from the user, but there are ways to step into the environment to help with debugging:
runs the build up to the lifecycle step specified and opens a shell within the build environment.
snapcraft prime --shellwill the build up to the
stagestep and open a shell.
runs the build up to and through the lifecycle step specified and opens a shell within the build environment.
snapcraft prime --shell-afterwill open a shell after the
primestep has been processed.
opens a shell inside the build environment after an error occurs.
Migrating snaps to bases
To make the transition to bases easier, base functionality is only triggered when adding the
base keyword in
Both snapd and snapcraft remain compatible non-base snap configurations, but these snaps cannot take advantage of the latest features. Additionally, with no base defined, snapcraft runs in a special 2.x compatibility mode that lacks the options found in later releases.
Features no longer available with bases
base keyword is used within
snapcraft.yaml the following, long-deprecated, features are no longer available:
wiki parts and their corner case quirks, such as allowing
/(forward slash) in parts.
cleanbuildand triggering builds using LXD from certain environment variables. See Build on LXD for more details.
installkeywords, used in parts, have been replaced by
snapcraftctl. This means you can use
snapkeyword has been superseded by the
- when calling build commands through snapcraft,
--disable-parallel-buildis no longer available. It can be setup per-part using the build-attributes property.
- similarly, when calling build commands through snapcraft,
stage-packages) is no longer available.
Migrating from deb to snap
On Ubuntu and its derivatives, the deb package of Snapcraft may have been installed via the desktop package manager, or the
apt command, and cannot be upgraded to Snapcraft 3.x. You can check by locating the snapcraft executable.
The following location indicates installation from a deb:
$ which snapcraft /usr/bin/snapcraft
The following is the executable location for a snap:
$ which snapcraft /snap/bin/snapcraft
To migrate from a deb snapcraft installation to a snap, first remove the deb package and then install the snap:
sudo apt autoremove --purge snapcraft sudo snap install snapcraft --classic
The latest version of the snap will now be installed and will remain updated.
Last updated 3 years ago.