Vagrant for Snap development

Posted on August 30, 2018

EDIT: Most likely these instructions no longer work for developing Snaps if you are using base: core18. If a base is specified then multipass is used to emulate the environment using KVM which is not supported by VirtualBox. Please try simply the snapcraft command on physical hardware first.

The only way I have found to develop Snap packages on Arch Linux is to use a Ubuntu 16.04 virtual machine to do the development. Getting the vagrant machine is straight forward. You’ll first need to add the image to the Vagrantfile like so:

I’ve also upped the memory to 4 GB because I was getting some out of memory errors on a Snap build.

Now you should be able to vagrant up and vagrant ssh to enter the vagrant VM and work on the snap.

The only other caveat is that you’ll not be able to build the Snap in /vagrant which is where the VM shares files with the host. You’ll need to copy your snapcraft.yml file into another directory. I create a ~/projects/mySnapProject directory to hold my Snap projects. I would then copy the snapcraft.yml and other project files into the ~/projects/mySnapProject directory.

Knowing all of this you should be able to follow the snapcraft setup to start building snaps. Although, the snapcraft cleanbuild did not work for me with the build I was created. I resorted to building with only the snapcraft command.

Once the .snap file is created it can be copied into /vagrant so that it can be installed on the host machine, tested and published.

Here are a couple of issues I had getting started which I posted on the Snapcraft Forum.

Modified: January 29, 2019 - 08:54:08 PM