Julia on Ubuntu 22.04

AI added the following code to my run_julia script:

# Preload Julia-bundled libraries to avoid version conflicts with older system libs.
# On Ubuntu 22.04: OpenSSL 3.0.2 (artifacts need 3.3+), fontconfig 2.13 (missing
# FcConfigSetDefaultSubstitute added in 2.15). The dynamic linker reuses already-loaded
# system libs instead of the bundled ones, so we force the bundled versions in first.
_PRELOADS=()
_BUNDLED=$(find ~/.julia/artifacts -maxdepth 3 -name "libcrypto.so.3"   -path "*/lib/*" 2>/dev/null | head -1); [[ -n "$_BUNDLED" ]] && _PRELOADS+=("$_BUNDLED")
# Pick the fontconfig that exports FcConfigSetDefaultSubstitute (needed by Pango ≥ 1.57).
# Multiple artifact versions may coexist; `find | head -1` can return the wrong one.
_BUNDLED=""
for _fc in $(find ~/.julia/artifacts -maxdepth 3 -name "libfontconfig.so.1" -path "*/lib/*" 2>/dev/null); do
    if nm -D "$_fc" 2>/dev/null | grep -q FcConfigSetDefaultSubstitute; then
        _BUNDLED="$_fc"
        break
    fi
done
[[ -n "$_BUNDLED" ]] && _PRELOADS+=("$_BUNDLED")
if [[ ${#_PRELOADS[@]} -gt 0 ]]; then
    export LD_PRELOAD=$(IFS=:; echo "${_PRELOADS[*]}")
fi
unset _PRELOADS _BUNDLED

Is this a reasonable workaround for so file version mismatch errors on older Linux distros?

And is there anything that could be done on the Julia side to make such workarounds superfluous?

Danger, Will Robinson. Jammy goes out of LTS in April 2027, so you are going to need to go to Noble before long, anyway. Why take the risk that some other process is going to get confused and try to load the wrong version? (Note to self; update LAN server.)

An appropriate runtime library search path (rpath) is set in the julia binaries and in almost all artifacts in the Julia ecosystem, so library preloads are rarely needed. (FWIW, I’ve been doing much of my Julia development on Ubuntu 22 recently and haven’t needed preloads for Julia-related things in the last couple of years.) In particular, Julia and properly built JLLs should not use the specific system libraries mentioned in your snippet.

The exceptions I can think of are third-party libraries - for example, some brought in by PythonCall. (The Python folks seem to have gotten better about this lately, too.)

So if you encounter mismatches within the Julia ecosystem, please file an issue or post here if you don’t know where the issue belongs.

If you do need the workaround while waiting for a fix or because of externalities, the find commands above should have “-H” flags if you or your sysadmin are using any symlinks.