Trouble with the gnome-3-34 extension: possible version mismatch between the libgtk-3.so.0 and libpango

I’m using the gnome-3-34 extension to package my application based on GTK3 and PyGObject. I’m getting a runtime error that I believe is due to a mismatch in library versions.

/snap/alpha/x1/gnome-platform/usr/lib/x86_64-linux-gnu/libgtk-3-0/gtk-query-immodules-3.0: symbol lookup error: /snap/alpha/x1/gnome-platform/usr/lib/x86_64-linux-gnu/libgtk-3.so.0: undefined symbol: pango_font_description_set_variations
ERROR: /snap/alpha/x1/gnome-platform/usr/lib/x86_64-linux-gnu/libgtk-3-0/gtk-query-immodules-3.0 exited abnormally with status 127

** (alpha:8170): WARNING **: 02:48:23.074: Failed to load shared library 'libgtk-3.so.0' referenced by the typelib: /snap/alpha/x1/gnome-platform/usr/lib/x86_64-linux-gnu/libgtk-3.so.0: undefined symbol: pango_font_description_set_variations

I’ve tried to make a minimal example that reproduces the issue but am having a tough time reproducing the problem in a small example. There is something mysterious around the gnome-3-34 extension that apparently brings in the necessary libraries.

Does somebody know how I could fix this issue?

If you are using stage-packages,maybe filter out the libraries provided by the extension that would come from there.

From my system:

james@scruffy:/snap/gnome-3-34-1804/current/usr/lib/x86_64-linux-gnu$ nm -D libgtk-3.so.0 | grep pango_font_description_set_variations
                 U pango_font_description_set_variations
james@scruffy:/snap/gnome-3-34-1804/current/usr/lib/x86_64-linux-gnu$ nm -D libpango-1.0.so.0 | grep pango_font_description_set_variations
00000000000167e0 T pango_font_description_set_variations
0000000000016730 T pango_font_description_set_variations_static

Is it possible you have a copy of libpango-1.0.so.0 earlier in the library search path for your snap?

Thanks for the advice @jamesh. So I did snap run --shell myprogram and then ran printenv in the shell. I get a whole lot of paths for LD_LIBRARY_PATH that are all under the /snap directory and one in /var/lib/snapd.

Here are the versions of libpango that I find:

=> sudo find /snap/ -name "libpango-1.0.so.0"
/snap/gnome-3-34-1804/36/usr/lib/x86_64-linux-gnu/libpango-1.0.so.0
/snap/gnome-3-34-1804/33/usr/lib/x86_64-linux-gnu/libpango-1.0.so.0
/snap/spotify/36/usr/lib/x86_64-linux-gnu/libpango-1.0.so.0
/snap/spotify/41/usr/lib/x86_64-linux-gnu/libpango-1.0.so.0
/snap/alpha/x1/usr/lib/x86_64-linux-gnu/libpango-1.0.so.0

So I guess my setup.py was pulling in the wrong version of the library with install_requires. I removed the inclusion of pycairo from my setup.py and added python3-gi-cairo instead to stage-packages. The same problem persists.

Is there an easy way to figure out which lines are responsible for installing that version of libpango?

You could also use the cleanup part to remove all libraries which are already present in the gnome-3-34 platform snap.

Thank you @galgalesh. That looks like a great solution.

I’ve tried it and am running into another problem, however: After cleanup part, command not found in the prime directory, but it's there.

Would you have any clue what is going on there?