In order to build a snap, is it important that I build it in Ubuntu 18 LTS

In order to build a snap, is it important that I build it in Ubuntu 18 LTS. I tried building the snap in Ubuntu 16.04 LTS, but it is failing. Also once the snap is built, the same needs to be installed in Ubuntu Core. What is the way forward ?

it is always important that you build your snap on the target release your base: definition in snapcraft.yaml points to … so for

base: core 

you use 16.04

base: core18 

expects an 18.04 build environment and

base: core20 

likewise a 20.04 one

since not eveyone is running one of these three releases above, snapcraft defaults to using a VM (multipass) for building … if you do not like this because it eats extra resources, you can use the --use-lxd option. with a properly set up lxd installation on the host and this option set, snapcraft will use lxd containers with the proper target version for building …

and last but not least, you can manually create an lxd container, use lxc shell <containername> to enter it, run snap install snapcraft --classic inside that container and run snapcraft with the --destructive-mode option to build inside this container …

if you want that last bit in an automated way, you can also install the fabrica snap:

that will automatically build any git tree you point it at …

there is also always that you could simply use remotely …

The contents of my snapcraft.yaml is below:

name: hello
base: core
version: ‘2.10’
summary: GNU Hello, the “hello-world” snap
description: |
This is my-snap’s description. GNU hello, prints a friendly greeting
grade: devel # must be ‘stable’ to release into candidate/stable channels
confinement: devmode # use ‘strict’ once you have the right plugs and slots

# See ‘snapcraft plugins’
plugin: autotools

When I run the above by running the command $ snapcraft --use-lxd

I get the below error:

The ‘LXD’ provider does not support having the ‘lxd’ or ‘lxd-client’ deb packages installed. To completely migrate to the LXD snap run
‘lxd.migrate’ and try again.

Please note that the Ubuntu version is 16.04 LTS on which I am trying to build the snap

well, did you do what it asks you to do ? (i.e. make sure to have the lxd snap installed, use the lxd.migrate command to get your older containers moved over and remove all the old lxc/lxd deb packages)

After running the command lxd.migrate and then again running snapcraft --use-lxd. Attached is the output

Still I am not getting the desired result

Looks like a network failure inside your lxd container. I have seen this when the lxd init step was done and ipv6 was enabled. When I configure lxd I never enable ipv6.

1 Like

@ogra I have created a fresh ubuntu VM wth 16.04.LTS. Using the same yaml file I was able to create the snap, however when I try to install it I get the attached error

you want --dangerous not --devmode to install local snaps

Will try with --dangerous as well, however I installed snapd by running the command $ sudo apt install snapd

After installing snapd, I tried to install the snap again, it does proceed but now it hangs. Attached screenshot

you are still using --devmode there …

I figured out the problem. The problem was in the yaml file. I changed base: core to base: core16,
Created the snap again
Ran it and it works fine

1 Like

Now, my next question is how do I install a software in Ubuntu core, obviously I will have to create a snap for the same. Do you have any reference which I can relate to

how about:

once you are through this, it ends with a “Further readings” paragraph that has links to other docs and tutorials…

OK, I created this test snap, using this document only