Snapcraft can be installed on all popular Linux distributions compatible with systemd,as well as macOS and Windows.
Before you begin installation and setup, make sure your system meets thesystem requirements.
A working Snapcraft setup has two components – Snapcraft itself, and a buildprovider.
If your Linux distribution has snapd installed, the easiest way to installSnapcraft is from the Snap Store:
snapinstallsnapcraft--classic
First,install WSL2 with Ubuntu 20.04 or higher.
Then, install Snapcraft in WSL2:
snapinstallsnapcraft--classic
Snapcraft relies on abuild provider to create an isolated build environment, like asandbox. Inside this environment, software can be built and packaged as snaps withoutmaking potentially destructive changes to the host system.
Build provider | Description | Default on |
Creates and manages Linux container images. It can operate inside VMs. | Snapcraft 7 and higher on Linux | |
Creates and manages virtual machine (VM) build instances. It automates setup andteardown of cloud-style Ubuntu VMs. It can’t be used reliably on platforms thatdon’t support nested virtualization. In other words, it most likely won’t runinside another VM. |
|
When you first run Snapcraft, it installs the default build provider for your hostplatform. If the default build provider isn’t suitable, you can install the alternativeand thenswitch to it.
Install the LXD snap:
snapinstalllxd
LXD has special requirements from your local user account that Snapcraft can’t managefor you during its automatic setup. Add your user account to thelxd group so youcan access the LXD daemon:
sudousermod-a-Glxd$USERLog out and back in to your local user account for the new group to take effect. Then,check that you’re a member of the group by running:
groups$USERThe list should containlxd.
Finnally, initialize LXD with a lightweight configuration:
sudolxdinit--auto
If you need help troubleshooting your LXD installation, seeHow to install LXD in the LXDdocumentation.
Install the Multipass snap:
snapinstallmultipass
Tip
With core20 snaps and Multipass, the default virtual machine is assigned 2CPUs and 2GB of RAM. To extend the hardware capacity, you can set thefollowing environment variables to modify CPU and memory allocation, andimprove performance:
exportSNAPCRAFT_BUILD_ENVIRONMENT_CPU=8exportSNAPCRAFT_BUILD_ENVIRONMENT_MEMORY=16G
If you’re installing Snapcraft as a snap, you can install multiple concurrentversions at the same time. Doing so could come in handy if you want to test newfeatures in your snaps, before they arrive in a mainstream release.
First, enable parallel installs in snapd:
snapsetsystemexperimental.parallel-instances=true
List all the available versions of Snapcraft. For the version you’re interested in, takenote of the value in the channel column.
snapinfosnapcraft
Install a new instance of Snapcraft with theinstance key naming syntax, replacing<instance> with whichever name is appropriate for the instance, and<channel>with the target channel and track:
snapinstallsnapcraft_<instance><channel>--classic
For example, you could install the very latest official releases with:
snapinstallsnapcraft_edgelatest/edge--classic
Whenever you want to run this parallel version of Snapcraft, invoke the instance name ofthe command – in this example,snapcraft_edge.