Do you really need LXD?

So I started down the snapcraft path and totally missed the instructions about LXD (install and use) and was making a lot of progress when I then noticed the instructions about installing/using LXD at:
https://docs.snapcraft.io/build-snaps/get-started-snapcraft

This got me totally derailed as I inadvertently installed the LXD Debian package instead of the LXD snap and ran into (known) problems (‘snapcraft cleanbuild’ failures), so I then uninstalled the .deb and eventually out of frustration uninstalled the LXD snap as well and now I’m back to successfully creating .snaps. So what gives? Is LXD really needed or it is just an obsolete requirement that wasn’t removed from the docs?

Thanks,

-Rob

It is primarily a clean build environment.

Have a peek at the first paragraph on this post as it gives a trail high level chunk of info.

1 Like

In fact, snapcraft’s cleanbuild is practically creating a new LXD container and run the build in it. The point is to provide a clean environment while not contaminating your working environment and is VERY useful. The LXD installation is from snap or debian package shouldn’t really matter much(though personally I never tried the snap installation), if it does then maybe there’s a bug to deal with.

Here’s a tutorial I wrote for making an LXD container for snap developing without the cleanbuild’s “feature” that destroys the container everytime a build is ended:

Also if you encountered issues when running snapcraft cleanbuild there’s an --debug option to make it drop into a shell and let you debug the problem.

@rswindell At the time of writing snaps need to be built using an Ubuntu 16.04 host/container/VM. Installing LXD allows you to run Ubuntu 18.04 yet still build in 16.04 containers. More importantly, using LXD containers and snapcraft cleanbuild ensure you have a clean build environment for your snaps.

However, we do realise that using LXD and snapcraft cleanbuild is not an obvious route. To remedy this the Snapcraft team have been working on “Build VMs” to transparently create clean build environments for you. You can read more about it here:

1 Like