This can be fixed by adding binutils
to the base snap or as a stage package in the app snap. I think we should petition to include this deb package in all the core*
snaps as a common requirement for many snaps, especially python snaps that require to use cpython library loading via pip packages.
I haven’t tested this, but I surmised the above due to the following code in the linked file:
def find_library(name):
# See issue #9998
return _findSoname_ldconfig(name) or \
_get_soname(_findLib_gcc(name)) or _get_soname(_findLib_ld(name))
Both _findSoname_ldconfig
and _findLib_gcc
fail and fall through to _findLib_ld
. The configured LD_LIBRARY_PATH
is only inspected in this latter function (_findLib_ld
), which requires ld
to be accessible on the PATH. The ld
executable is included in the binutils
package. Therefore we can get python to respect the LD_LIBRARY_PATH
when loading shared objects within cpython by making ld
available (i.e. installing binutils
either in the base snaps - core, core18, core20, core22, et al - or by installing binutils
into every snap that uses python with cpython libraries)
Edit to add link to the _findLib_ld
function: https://github.com/python/cpython/blob/fa6304a5225787054067bb56089632146d288b20/Lib/ctypes/util.py#L300