The latex command inside snap can't find specific share lib


#1

Hello,

My anki-snap (https://github.com/woodrow-shen/anki-snap/blob/snap-packaging/snap/snapcraft.yaml) has a add-on function to call latex & dvipng for rendering. When a new card is created using latex syntax, the dialogue shows the following error:

latex: error while loading shared libraries: libpng16.so.16: cannot open shared object file: No such file or directory

Meantime, I check libpng16.so.16 is under /snap/anki-woodrow/current/usr/lib/x86_64-linux-gnu/

ls -1 /snap/anki-woodrow/current/usr/lib/x86_64-linux-gnu/libpng*
/snap/anki-woodrow/current/usr/lib/x86_64-linux-gnu/libpng16.a
/snap/anki-woodrow/current/usr/lib/x86_64-linux-gnu/libpng16.so
/snap/anki-woodrow/current/usr/lib/x86_64-linux-gnu/libpng16.so.16
/snap/anki-woodrow/current/usr/lib/x86_64-linux-gnu/libpng16.so.16.34.0
/snap/anki-woodrow/current/usr/lib/x86_64-linux-gnu/libpng.a
/snap/anki-woodrow/current/usr/lib/x86_64-linux-gnu/libpng.so

And, latex lib dependency can be found from debugging:

$ snap run --shell anki-woodrow.anki
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
 
$ which latex
/snap/anki-woodrow/19/usr/bin/latex
$ ldd /snap/anki-woodrow/19/usr/bin/latex
	linux-vdso.so.1 (0x00007ffdfd7c3000)
	libpng16.so.16 => /snap/anki-woodrow/19/usr/lib/x86_64-linux-gnu/libpng16.so.16 (0x00007f741ac6e000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f741aa51000)
	libpoppler.so.73 => /snap/anki-woodrow/19/usr/lib/x86_64-linux-gnu/libpoppler.so.73 (0x00007f741a5bb000)
	libkpathsea.so.6 => /snap/anki-woodrow/19/usr/lib/x86_64-linux-gnu/libkpathsea.so.6 (0x00007f741a3a2000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f741a019000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f7419c7b000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f7419a63000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7419672000)
	libfreetype.so.6 => /snap/anki-woodrow/19/usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f74193be000)
	libfontconfig.so.1 => /snap/anki-woodrow/19/usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f7419179000)
	libjpeg.so.8 => /snap/anki-woodrow/19/usr/lib/x86_64-linux-gnu/libjpeg.so.8 (0x00007f7418f11000)
	libnss3.so => /snap/anki-woodrow/19/usr/lib/x86_64-linux-gnu/libnss3.so (0x00007f7418bcd000)
	libsmime3.so => /snap/anki-woodrow/19/usr/lib/x86_64-linux-gnu/libsmime3.so (0x00007f74189a1000)
	libnspr4.so => /snap/anki-woodrow/19/usr/lib/x86_64-linux-gnu/libnspr4.so (0x00007f7418764000)
	liblcms2.so.2 => /snap/anki-woodrow/19/usr/lib/x86_64-linux-gnu/liblcms2.so.2 (0x00007f741850c000)
	libtiff.so.5 => /snap/anki-woodrow/19/usr/lib/x86_64-linux-gnu/libtiff.so.5 (0x00007f7418295000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f7418076000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f741b1fd000)
	libexpat.so.1 => /snap/anki-woodrow/19/lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f7417e44000)
	libnssutil3.so => /snap/anki-woodrow/19/usr/lib/x86_64-linux-gnu/libnssutil3.so (0x00007f7417c15000)
	libplc4.so => /snap/anki-woodrow/19/usr/lib/x86_64-linux-gnu/libplc4.so (0x00007f7417a10000)
	libplds4.so => /snap/anki-woodrow/19/usr/lib/x86_64-linux-gnu/libplds4.so (0x00007f741780c000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f7417608000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f7417400000)
	liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f74171da000)
	libjbig.so.0 => /snap/anki-woodrow/19/usr/lib/x86_64-linux-gnu/libjbig.so.0 (0x00007f7416fcc000)

Right now I have no idea what happened on this, so I’m looking for help from all snapcrafters.

Thanks,