Build options

By default, Snapcraft uses LXD or Multipass to simplify the build process and to confine the build environment within a virtual machine. For most developers, this happens transparently and is the best way to build snaps.

But to cater for different operating systems, environments and requirements, Snapcraft also offers a number of flexible options for how it can be run. These are outlined below.

Currently supported

Command Description Requirements
Uses LXD or Multipass to builds the snap within an instantiated VM to ensure a clean, isolated, build environment. Nested VMs require accelerated/nested VM functionality. Any supported system with VM capabilities.
snapcraft remote-build Remote build runs a multi-architecture build process on remote servers using Launchpad. Prospective snaps need to be open source as the code will be publicly available, plus a Launchpad account.
Build from GitHub Build from GitHub is another remote build option, triggering automatic snap builds from your developer account. Requires snap source hosted on a public GitHub repository, and account linking between GitHub and your developer account.
electron-builder -l snap Electron builder integration enables Electron app developers to easily create snaps with a simple modification to package.json . Requires Electron-builder with Linux or macOS snapcraft from the Snap Store or brew.

Snaps build on the bases core, core18, and core20 default to using Multipass as the build provider. core22 snaps use LXD on linux systems. Other systems (macOS and Windows) use Multipass.

See this page for details on how to configure snapcraft to use either LXD or Multipass and other build provider-specific details.

Build environment options

Snapcraft can optionally use the following arguments to modify the build environment.

Snapcraft argument Description Requirements
--destructive-mode Destructive mode. Designed to be used in temporary/short-lived environments, such as on a CI system, because the build could contaminate the host build environment. Needs access to Ubuntu 18.04 (core18) or 16.04 (core16 / core), alongside snapcraft, from the Snap Store.
--use-lxd LXD container. Builds the snap using LXD, rather than Multipass. This can potentially reduce resource usage, especially from a VM.
Set SNAPCRAFT_BUILD_ENVIRONMENT=lxd to use LXD by default.
Requires LXD
--http-proxy <http-proxy> Configures HTTP proxy. Snapcraft will honour http_proxy environment flag as well. None
--https-proxy <https-proxy> Configures HTTPS proxy. Snapcraft will honour https_proxy environment flag as well. None
--add-ca-certificates <path> Adds trusted CAs in Snapcraft-created build environments. May be a CA certificate file or directory containing certificate files.
Not currently compatible with Snapcraft 7.x
LXD, Multipass
--bind-ssh Bind ~/.ssh directory to local build instance. LXD, Multipass
--ua-token Configure build environment with ESM using specified UA token. LXD, Multipass

Deprecated build options

Command Description Requirements
snapcraft cleanbuild Cleanbuild. Legacy non-bases method for building snaps in a LXD container. Deprecated with the release of Snapcraft 3.x and no longer supported.
apt install snapcraft Snapcraft deb package. Originally used to install snapcraft on Ubuntu-based Linux distributions (and Debian). Outdated and no longer supported. See Snapcraft overview for current installation instructions.
snapcraft --offline Allow snapcraft to build snaps on a system without a network connection provided that 1) the build environment is prepared, and 2) all sources and packages required by the parts are already on the local system (that usually means that snapcraft pull was successfully executed when networking was still available). None

Deprecated Snapcraft argument

Snapcraft argument Description Requirements
--enable-manifest Deprecated and removed in core24. Add the build manifest to the snap package in snap/manifest.yaml. This contains the specific sources and packages used to build the snap and allows the Snap Store to automatically check your Snap for security issues. Setting the environment variable SNAPCRAFT_BUILD_INFO=1 to add build manifest is still supported. Snaps built on Launchpad will have this set automatically. None

A supported Linux system is a host or VM running a snap-capable Linux distribution. See Installing snapd for details.

Last updated a month ago.