The linker version '2.23' used by the base 'core' is incompatible with files in this snap:

Files from the build host were migrated into the snap to satisfy dependencies that would otherwise not be met. This feature will be removed in a future release. If these libraries are needed in the final snap, ensure that the following are either satisfied by a stage-packages entry or through a part:
usr/lib/x86_64-linux-gnu/libodbc.so.2
The linker version '2.23' used by the base 'core' is incompatible with files in this snap:
    /home/me/s2-integrati/prime/usr/lib/x86_64-linux-gnu/libgnutls.so.30.14.10 (2.25)
    /home/me/s2-integrati/prime/usr/lib/x86_64-linux-gnu/libp11-kit.so.0.3.0 (2.26)
name: my-app
version: git
summary: -
description: -

grade: devel
confinement: devmode

apps:
  my-app:
    command: my-app

parts:
  odbc-config:
    source: resources
    plugin: dump
    organize:
      'odbcinst.ini' : /etc/odbcinst.ini
  my-app:
    after: [odbc-config]
    plugin: nodejs
    node-engine: 8.8.1
    source: .
    stage-packages:
      - unixodbc
      - unixodbc-dev
      - odbc-postgresql
    build-packages:
      - build-essential
      - python

The purpose of this script is to bundle and load the drivers from ‘odbc-postgresql’ in the snap.

If you are not building on an Ubuntu 16.04 system, then use snapcraft cleanbuild or SNAPCRAFT_BUILD_ENVIRONMENT=lxd snapcraft (the second of those is a bit brittle). Both of these will build inside a clean Ubuntu 16.04 LXD container.

You will need LXD for those to work, so you should either install via APT or run:

sudo addgroup --system lxd
sudo adduser $USER lxd
sudo snap install lxd
# restart your desktop session so that the lxd group membership is applied
lxd init
# press enter to accept all the default options that it asks you
snapcraft cleanbuild # cooking with gas!
3 Likes

Thanks for the instructions. That solved the linker problem.

By the way: What is the right strategy to add ssh keys to snapcraft for npm packages (package.json)?

That’s a good question. I don’t believe we have a reasonable way of doing so right now. Especially when using container builds or the build.snapcraft.io service. You could bundle the key in your project, but that opens the doors to exploitation should someone nefarious find it such as if your project is visible publicly on github for example. To bundle in your project you’d need an additional part that runs before your other parts by setting the other to include after: [ssh-key] or some such and in your ssh-key part you’d include an override-build or override-pull script that copies the ssh key to somewhere default on the system e.g. $HOME/.ssh/id_rsa.

1 Like

Is it possible to use lxd in a docker image of snapcraft like snapcore/snapcraft? I would like to use snapcraft for builds with circleci.

I tried to add snapd and lxd but it does not seems to work.

One can install and run docker within docker. But it is necessary to run the host container in privileged mode:

docker run --privileged ...

I can imagine, but have never tried it myself, that the same goes for running lxd in docker.

Looking here running lxd in docker is not a thing.

I look into using circleci on an actual machine instead of docker.

When you’re using the docker image you don’t need to use cleanbuild. You can instead just do snapcraft on it’s own and throw the container away when it’s finished:

docker run --rm -it -v $PWD:/project -w /project snapcore/snapcraft:stable snapcraft
1 Like

How come lxd is not required when using the docker image? What exactly is cleanbuild doing?

Because docker is another container technology like LXD, and a docker container specifically made for snapcraft is created for this purpose.

snapcraft cleanbuild simply creates an Ubuntu 16.04 LXD container for you, copies your source tree and installs snapcraft in it, and runs snapcraft in your source tree in the container.

The docker command directly maps your source tree directory into the container without copying and run snapcraft in the container. The difference of two commands is that one creates a temporary container for the job (and destroys it after it) and one uses an existing container(and probably add an additional temporary fs layer over it for building, I’m not really familiar with Docker and is conservative about this).

It is technically possible to do the similar mapping thing in LXD, but not supported by snapcraft: Bug #1788774 “cleanbuild should use host filesystem mapping (dis…” : Bugs : Snapcraft

1 Like

I’m in this very linker version problem. However, building an LXC didn’t work:

$ snapcraft cleanbuild
Creating snapcraft-chokingly-nonrioting-ceola
Error: Failed container creation: Create container: Create LXC container: Invalid devices: Detect root disk device: No root device could be found
Failed to create container: a new LXD container could not be created.
Refer to the documentation at https://linuxcontainers.org/lxd/getting-started-cli.

I use LXD everyday, so I’m positive it works in my machine. Note though that I don’t use the default storage for it, but a different disk:

$ lxc storage list
+---------+-------------+--------+--------------------+---------+
|  NAME   | DESCRIPTION | DRIVER |       SOURCE       | USED BY |
+---------+-------------+--------+--------------------+---------+
| default |             | dir    | /data/lxd-storage/ | 2       |
+---------+-------------+--------+--------------------+---------+

Any clues on how to make this work? Thanks!!

It looks that this post is outdated: lxd is no longer required for building snaps.

If you specify “base: core16” or “base: core18” in the snapcraft yaml, it’ll build it in a VM.

1 Like