Snapcraft blocks hypervisor (Virtualbox)

I have a problem when running snapcraft. After snapcraft has finished I can not launch virtual machines via Virtualbox:


In order to launch a virtual machine I need to issue first

$ snapcraft clean

after which virtual machines can be started as normal. This works but is very annoying since I use virtual machines for testing modified snaps. So when I make modifications to the snap and re-run snapcraft it needs to re-create the snap from scratch which takes ages.

Is there a simpler way to release the hypervisor from snapcraft so I can launch virtual machines without having to clean the whole snap?

1 Like

This is in fcat not snapcraft blocking your hypervisor, but the multipass VM … you can make snapcraft use lxd containers instead of multipass …

$ sudo snap install lxd
$ sudo lxd init --auto

now you should be able to use snapcraft with the --use-lxd option (you might need to log out and back in again to be in the newly added lxd group so you do not need sudo for unprivileged containers) so your builds run in an lxd container and do not touch the hypervisor at all …

Hi @ogra,
thanks for your reply. I followed your instructions and made sure that I am now in the group “lxd”.
I then issued

$ snapcraft clean

$ snapcraft --use-lxd

However I now get the following error:

An error occurred when trying to communicate with the ‘LXD’ provider: cannot connect to the LXD socket (’/var/snap/lxd/common/lxd/unix.socket’)…

Any suggestions?

did you also run the lxd init command from above ?

Yes I did run

$ sudo lxd init --auto

there is a bit more info in teh snapcrft documentation at:

Thanks @ogra, it seems to be working now, i.e. it has started the build.
Not sure why, I just repeated the assignment to the lxd group by issueing

$ sudo usermod -a -G lxd ${USER}
$ newgrp lxd

Not sure why it didn’t work before.

1 Like