Stage packages should bring requirements

I’m working on a snap package for a Go program. The documentation hints that shared libraries are automatically discovered via ldd and added to the package, but this did not seem to work in my case, so I added my dependencies to stage-packages:

    stage-packages:
      - libhwloc5
      - ocl-icd-libopencl1
      - libwebkit2gtk-4.0-37

Starting the snap gave my this error:

error while loading shared libraries: libgcrypt.so.20: cannot open shared object file: No such file or directory

What’s weird about this is that I don’t even use libgcrypt, instead it’s a dependency of webkitgtk. I tried adding libgcrypt to stage-packages and now I get:

error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

I could probably keep doing this until I’ve covered all 500-something dependencies, but that’s surely not how it’s intended to work, right?

My snapcraft.yml, snap on snapcraft.io

1 Like

Yeah, if that’s happening it looks like dependencies are not being followed through, and it would definitely make sense for them to be.

@sergiusens?

Yes and no; this is hidden at the moment and should be exposed to the user so they know what is going on.

A long time ago, in a galaxy far far away, someone created this list (@mvo I believe you gave me the explanation of the reason for this list back then).

In that list, there are packages like libc6 which is where the dependency chain is cut to avoid bringing it in (it will be brought in if explicitly listed though). While libc6 may be obvious (and to be fair, it may not to everyone), there are other libraries in that list, such as libgcrypt20.

So we need to do two things here; provide a summary of what has been skipped and more importantly, explain why it is being skipped. I am mostly certain this list comes from packages that were in core back then and that list has changed somewhat from when it was first crafted all the way to when 16 was released.

Here’s the issue for _tracking` purposes, let’s keep having a discussion here if needed :slight_smile:

1 Like

That makes sense, but where are these libraries supposed to come from instead? The host system? Definitely does not work for me with confinement: strict on Solus, I do have libgcrypt.so.20 but still get the error.

… they come from the core snap (which is the “rootfs” all snaps are run on top of)

Then why are they missing at runtime (see error in OP)? Sorry I’m really confused right now…

1 Like

well, they are definitely there, the question is why are they not in your LD_LIBRARY_PATH at runtime or does your app (being go) perhaps ignore this var or some such … ?

ogra@styx:~$ sudo find /snap/core/ -name '*libgcrypt*'|grep -v doc
/snap/core/3604/lib/x86_64-linux-gnu/libgcrypt.so.20
/snap/core/3604/lib/x86_64-linux-gnu/libgcrypt.so.20.0.5
/snap/core/3887/lib/x86_64-linux-gnu/libgcrypt.so.20
/snap/core/3887/lib/x86_64-linux-gnu/libgcrypt.so.20.0.5
/snap/core/3748/lib/x86_64-linux-gnu/libgcrypt.so.20
/snap/core/3748/lib/x86_64-linux-gnu/libgcrypt.so.20.0.5
ogra@styx:~$ sudo find /snap/core/ -name '*libz*'|grep -v doc
/snap/core/3604/lib/x86_64-linux-gnu/libz.so.1
/snap/core/3604/lib/x86_64-linux-gnu/libz.so.1.2.8
/snap/core/3887/lib/x86_64-linux-gnu/libz.so.1
/snap/core/3887/lib/x86_64-linux-gnu/libz.so.1.2.8
/snap/core/3748/lib/x86_64-linux-gnu/libz.so.1
/snap/core/3748/lib/x86_64-linux-gnu/libz.so.1.2.8

How are you starting the snap? Can you detail the steps please (as verbose as can be)?

I just set up a fresh Ubuntu VM and did a snapcraft cleanbuild and it actually worked! I think build.snapcraft.io borked the build, it even appears to be completely stuck now, only armhf is building.

For the record, the reproduction steps are as simple as:

$ sudo snap install --edge blockforge 
$ blockforge
/snap/blockforge/17/bin/blockforge: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

But this will hopefully be fixed with the next rebuild.

1 Like

There is a large queue on the i386 and amd64 builders right now, so builds are taking about 3 hours to start.

ref: https://launchpad.net/builders

it looks like this could actually be a bug in snapcraft itself …

there the libz error is more clear (with the full error line):

/snap/snapcraft/1094/usr/bin/mksquashfs: error while loading shared libraries: liblz4.so.1: cannot open shared object file: No such file or directory

Nice spotting @ogra, I guess 2.39.1 is going to be out the door soon