I’m working on a snap that depends on libEGL.so. I’m building the snap with the core20 base using --use-lxd. I found that when running the snap, it will load libEGL.so from the host, resulting in the following error:
/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /var/lib/snapd/lib/gl/libEGL.so.1)
This is because I’m running 21.10 which ships with glibc 2.33, but the 20.04 base uses glibc 2.31. To amend this, earlier I copied libEGL.so.1 from the build environment to $SNAP/lib and set LD_LIBRARY_PATH in a wrapper script to contain that as the first item.
Now I need to debug a crash and found that the debugger attaches to the shell, meaning I can’t get meaningful information out of it. I figured it’s best to get rid of the wrapper script anyway and set my environment in the yaml:
environment:
LD_LIBRARY_PATH: $SNAP/lib:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/apulse:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/dri
however, when I run this newly built snap, it will again try to load libEGL from the host system. If I run snap run --shell
and print LD_LIBRARY_PATH I see that it injects a bunch of paths before my custom path:
/var/lib/snapd/lib/gl:/var/lib/snapd/lib/gl32:/var/lib/snapd/void:/snap/plex/x1/lib:/snap/plex/x1/usr/lib/x86_64-linux-gnu/apulse:/snap/plex/x1/usr/lib/x86_64-linux-gnu:/snap/plex/x1/usr/lib/x86_64-linux-gnu/dri:/snap/plex/x1/lib:/snap/plex/x1/usr/lib:/snap/plex/x1/usr/lib/x86_64-linux-gnu
Is there a way to change this behavior?