Upgraded my system at home to 21.10, which is also NVIDIA only.
Built the OSB Studio snap (actually a test version called obs-demo) locally from my original yaml and added export LD_LIBRARY_PATH=${LD_LIBRARY_PATH#$SNAP_LIBRARY_PATH:} to the wrapper just before the exec.
OBS Studio is working.
I grabbed the LD_LIBRARY_PATH, before and after adding that export to the wrapper. This is the result. I’ve highlighted what is removed from the Before:
/var/lib/snapd/void is the directory where snap-confine will go when it is not safe/allowed to set the current working directory to anything else. If that directory is showing up in a variable then some part of the wrapper scripts is probably using $PWD (incorrectly).
Thanks for the info @ijohnson. So, my workaround to get the OBS Studio snap working on 21.10 for NVIDIA users, while preserving $SNAP_LIBRARY_PATH, is adding these two lines to my wrapper:
It’s snapcraft setting LD_LIBRARY_PATH, but the point of prepending is to pick up the host Nvidia GL library, not a mesa one from the snap content. Appending would defeat that. (The problem here is that it is problematic when the host and base userspace isn’t compatible.)
That LD_LIBRARY_PATH is baked into the snaps. Which means, if fixing this in snapcraft is the right place to address this, all affected snaps will need to be rebuilt and published in order that NVIDIA users can run them on 21.10 and the next LTS.
Perhaps updating the desktop extensions in Snapcraft and the legacy desktop-helpers, with a workaround like the one I am using, may also help. But still requires snaps are rebuilt and published.
The only workaround that doesn’t require “all” snaps to be rebuilt is for snapd to not mount the drivers/export stuff in SNAP_LIBRARY_PATH unless the host userspace matches the snap base.
Maybe the option is to stop symlinking libEGL.so.0* into /var/lib/snapd/lib/gl. It’s not part of the Nvidia drivers, and a version provided by the snap should be able to load the Nvidia libraries (provided those binary blobs are in fact compatible).
The main questions in making that change would be:
Are there supported systems out there not using glvnd but providing proprietary Nvidia drivers that snapd actually uses?
Are there supported EGL snaps out there that are not shipping (or plugging a content snap that ships) glvnd to access the Mesa drivers?