Snapcraft for Windows – Preview
by Igor Ljubuncic on 13 August 2021
Two weeks ago, Snapcraft reached its fifth milestone release, 5.0. This version brings in a number of significant changes, including the removal of the base (core) snap, which has been relegated to the 4.X channel track. For snap developers, especially those working in mixed environments, the availability of the first preview release of Snapcraft for Windows(!) will more likely be the interesting piece of good news.
Since its inception, the goal of Snapcraft has been to provide a robust, friendly development platform, regardless of your choice of operating system. The original Linux support has since been extended to macOS and now, Windows. You can build your snaps inside a Windows system, or upload them to the store, without having to have a Linux machine handy.
Caution, uncharted territory ahead!
Before you move on, please note that this is an initial, preview release. Some functionality may be missing, or things may not work as well as they should. We welcome tinkerers, early adopters and enthusiasts to take a look at the software, and provide any feedback they have.
Snapcraft comes with a single, guided GUI installer. You can configure the program for your own user (for which you don’t need administrative privileges), or for all users. The installer will also add the snapcraft executable to your path, so you can run the commands in any terminal or PowerShell window.
Once snapcraft is installed, you can run any snapcraft command. For instance, you may try to run snapcraft without a valid snapcraft.yaml file in place, which will result in the expected error message, just like in Linux. Or login and upload snaps to the store. You can also build snaps, but this requires some additional setup.
Building snaps in Windows
Snapcraft utilizes Multipass, a virtualization technology, as its backend engine for creating isolated Linux build instances, inside which snaps are built, without touching your underlying operating system in any way. In Linux, you can use either Multipass or LXD backends. In Windows, at the moment, Snapcraft supports Multipass – which you can install and use regardless.
By default, Multipass relies on the Hyper-V technology. This means you can use Snapcraft to build snaps only on those versions of Windows that offer this technology (Pro and higher). However, it is possible to reconfigure Multipass installed in a Home edition of Windows, to use a different virtualization backend. If you are not sure, you might want to wait out the early preview period until the bugs and issues are ironed out.
Conversely, if you really are into testing the bleeding-edge technologies, Snapcraft can also be installed and used in the Dev builds of Windows 11.
Some possible snags
If you’re curious how the whole thing works, but don’t necessarily want to run the commands yourself, here are some of the possible issues you may encounter. For example, you might try to run snapcraft (and build snaps) on a Home edition of Windows, which will eventually result in a failure, as Multipass cannot run by default on this version of the operating system.
Downloading 'multipass-1.7.0%2Bwin-win64.exe'[===========================] 100%
Verified installer successfully…
Failed to install Multipass: 'installation did not complete successfully'
Please install manually. You can find the latest release at:
To get Multipass working in a Home edition of Windows, you can change the virtualization driver that Multipass uses to spawn virtual machines (and for Snapcraft, build instances):
multipass set local.driver=virtualbox
Alternatively, you may be using the Professional version, but the Hyper-V technology hasn’t been installed and configured. You will need to manually do this yourself, restart your system, and then run Snapcraft again.
Verified installer successfully…
Multipass installation completed successfully.
Waiting for multipass…
Launching a VM.
launch failed: The Hyper-V Windows feature is disabled. Please enable by using the following
command in an Administrator Powershell and reboot:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
An error occurred with the instance when trying to launch with 'multipass': returned exit code 2.
Ensure that 'multipass' is setup correctly and try again.
Finally, once you get Multipass working, you need to make sure that the networking stack is configured properly, and that there are no firewall rules in place, which might prevent the virtual machines from communicating with the host and the Internet – to be able to download and setup the Ubuntu images for the snap build environment.
Snapcraft for Windows is an important addition to the snap ecosystem, offering developers across the operating system board to create and publish their applications with ease. At the moment, there might be some rough edges, but you can already make decent progress and test the functionality, including store-related commands and perhaps even build operations. We’d also appreciate feedback, so if you have anything to share, please join our forum and let us know what you think.