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 build.snapcraft.io 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

parts:
gnu-hello:
source: http://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz
# 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
snapcraft%20error%20part%201
snapcraft%20error%20part2

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.

@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 errorHello%20snap%20error

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 screenshotSnap%20hangs

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 finesnap%20works

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