How to set LD_LIBRARY_PATH properly?

I’m working on a snap that depends on I’m building the snap with the core20 base using --use-lxd. I found that when running the snap, it will load from the host, resulting in the following error:

/lib/x86_64-linux-gnu/ version `GLIBC_2.33' not found (required by /var/lib/snapd/lib/gl/

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 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:


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:


Is there a way to change this behavior?

1 Like

Tagging @niemeyer and @kenvandine as after upgrading to 21.10 I can confirm snaps using GL fail to run.

@Wimpress thanks! I think EGL-using snaps on impish seem to be broken when using the Nvidia proprietary driver is more relevant to the topic. Setting LD_LIBRARY_PATH in the yaml is a different issue (and can be worked around with a wrapper script).

1 Like

Yes, can confirm NVIDIA issue since the 3 main systems I use are NVIDIA. Will hope over to the other thread.