Linking error (?) with libz.so when precompiling Plots.jl

I’ve had this problem on a couple of HPC clusters (where the system libraries are relatively old). When trying to install/precompile Plots.jl, there’s an error because the system-provided libz.so is not version 1.2.9 (see error message below). Jullia’s packages include a version of libz.so (which I assume would be compatible) - why is this one not being used?

I’m not familiar with how Julia links shared libraries like this, so hints on fixing/debugging or even which package I should raise an issue with (if that is what needs doing) would be appreciated.

Error message (with user-name and system-specific info edited out):

$ julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _  |  |
  | | |_| | | | (_| |  |  Version 1.6.2 (2021-07-14)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

(@v1.6) pkg> add Plots
    Updating registry at `~/.julia/registries/General`
    Updating git-repo `https://github.com/JuliaRegistries/General.git`
   Resolving package versions...
    Updating `~/.julia/environments/v1.6/Project.toml`
  [91a5bcdd] + Plots v1.23.5
    Updating `~/.julia/environments/v1.6/Manifest.toml`
  [d360d2e6] + ChainRulesCore v1.11.1
  [35d6a980] + ColorSchemes v3.15.0
  [3da002f7] + ColorTypes v0.11.0
  [5ae59095] + Colors v0.12.8
  [34da2185] + Compat v3.40.0
  [d38c429a] + Contour v0.5.7
  [9a962f9c] + DataAPI v1.9.0
  [864edb3b] + DataStructures v0.18.10
  [e2d170a0] + DataValueInterfaces v1.0.0
  [c87230d0] + FFMPEG v0.4.1
  [53c48c17] + FixedPointNumbers v0.8.4
  [59287772] + Formatting v0.4.2
  [28b8d3ca] + GR v0.62.1
  [5c1252a2] + GeometryBasics v0.4.1
  [42e2da0e] + Grisu v1.0.2
  [cd3eb016] + HTTP v0.9.16
  [83e8ac13] + IniFile v0.5.0
  [3587e190] + InverseFunctions v0.1.1
  [92d709cd] + IrrationalConstants v0.1.1
  [c8e1da08] + IterTools v1.3.0
  [82899510] + IteratorInterfaceExtensions v1.0.0
  [b964fa9f] + LaTeXStrings v1.3.0
  [23fbe1c1] + Latexify v0.15.9
  [2ab3a3ac] + LogExpFunctions v0.3.4
  [1914dd2f] + MacroTools v0.5.9
  [739be429] + MbedTLS v1.0.3
  [442fdcdd] + Measures v0.3.1
  [e1d29d7a] + Missings v1.0.2
  [77ba4419] + NaNMath v0.3.5
  [ccf2f8ad] + PlotThemes v2.0.1
  [995b91a9] + PlotUtils v1.0.15
  [91a5bcdd] + Plots v1.23.5
  [3cdcf5f2] + RecipesBase v1.1.2
  [01d81517] + RecipesPipeline v0.4.1
  [189a3867] + Reexport v1.2.2
  [6c6a2e73] + Scratch v1.1.0
  [992d4aef] + Showoff v1.0.3
  [a2af1166] + SortingAlgorithms v1.0.1
  [90137ffa] + StaticArrays v1.2.13
  [82ae8749] + StatsAPI v1.0.0
  [2913bbd2] + StatsBase v0.33.12
  [09ab397b] + StructArrays v0.6.3
  [3783bdb8] + TableTraits v1.0.1
  [bd369af6] + Tables v1.6.0
  [5c2747f8] + URIs v1.3.0
  [1cfade01] + UnicodeFun v0.4.1
  [6e34b625] + Bzip2_jll v1.0.8+0
  [83423d85] + Cairo_jll v1.16.1+0
  [5ae413db] + EarCut_jll v2.2.3+0
  [2e619515] + Expat_jll v2.2.10+0
  [b22a6f82] + FFMPEG_jll v4.4.0+0
  [a3f928ae] + Fontconfig_jll v2.13.93+0
  [d7e528f0] + FreeType2_jll v2.10.4+0
  [559328eb] + FriBidi_jll v1.0.10+0
  [0656b61e] + GLFW_jll v3.3.5+1
  [d2c73de3] + GR_jll v0.62.0+0
  [78b55507] + Gettext_jll v0.21.0+0
  [7746bdde] + Glib_jll v2.68.3+0
  [3b182d85] + Graphite2_jll v1.3.14+0
  [2e76f6c2] + HarfBuzz_jll v2.8.1+0
  [aacddb02] + JpegTurbo_jll v2.1.0+0
  [c1c5ebd0] + LAME_jll v3.100.1+0
  [dd4b983a] + LZO_jll v2.10.1+0
  [e9f186c6] + Libffi_jll v3.2.2+0
  [d4300ac3] + Libgcrypt_jll v1.8.7+0
  [7e76a0d4] + Libglvnd_jll v1.3.0+3
  [7add5ba3] + Libgpg_error_jll v1.42.0+0
  [94ce4f54] + Libiconv_jll v1.16.1+1
  [4b2f31a3] + Libmount_jll v2.35.0+0
  [89763e89] + Libtiff_jll v4.3.0+0
  [38a345b3] + Libuuid_jll v2.36.0+0
  [e7412a2a] + Ogg_jll v1.3.5+0
  [458c3c95] + OpenSSL_jll v1.1.10+0
  [91d4177d] + Opus_jll v1.3.2+0
  [2f80f16e] + PCRE_jll v8.44.0+0
  [30392449] + Pixman_jll v0.40.1+0
  [ea2cea3b] + Qt5Base_jll v5.15.3+0
  [a2964d1f] + Wayland_jll v1.19.0+0
  [2381bf8a] + Wayland_protocols_jll v1.18.0+4
  [02c8fc9c] + XML2_jll v2.9.12+0
  [aed1982a] + XSLT_jll v1.1.34+0
  [4f6342f7] + Xorg_libX11_jll v1.6.9+4
  [0c0b7dd1] + Xorg_libXau_jll v1.0.9+4
  [935fb764] + Xorg_libXcursor_jll v1.2.0+4
  [a3789734] + Xorg_libXdmcp_jll v1.1.3+4
  [1082639a] + Xorg_libXext_jll v1.3.4+4
  [d091e8ba] + Xorg_libXfixes_jll v5.0.3+4
  [a51aa0fd] + Xorg_libXi_jll v1.7.10+4
  [d1454406] + Xorg_libXinerama_jll v1.1.4+4
  [ec84b674] + Xorg_libXrandr_jll v1.5.2+4
  [ea2f1a96] + Xorg_libXrender_jll v0.9.10+4
  [14d82f49] + Xorg_libpthread_stubs_jll v0.1.0+3
  [c7cfdc94] + Xorg_libxcb_jll v1.13.0+3
  [cc61e674] + Xorg_libxkbfile_jll v1.1.0+4
  [12413925] + Xorg_xcb_util_image_jll v0.4.0+1
  [2def613f] + Xorg_xcb_util_jll v0.4.0+1
  [975044d2] + Xorg_xcb_util_keysyms_jll v0.4.0+1
  [0d47668e] + Xorg_xcb_util_renderutil_jll v0.3.9+1
  [c22f9ab0] + Xorg_xcb_util_wm_jll v0.4.1+1
  [35661453] + Xorg_xkbcomp_jll v1.4.2+4
  [33bec58e] + Xorg_xkeyboard_config_jll v2.27.0+4
  [c5fb5394] + Xorg_xtrans_jll v1.4.0+3
  [3161d3a3] + Zstd_jll v1.5.0+0
  [0ac62f75] + libass_jll v0.15.1+0
  [f638f0a6] + libfdk_aac_jll v2.0.2+0
  [b53b4c65] + libpng_jll v1.6.38+0
  [f27f6e37] + libvorbis_jll v1.3.7+0
  [1270edf5] + x264_jll v2021.5.5+0
  [dfaa095f] + x265_jll v3.5.0+0
  [d8fb68d0] + xkbcommon_jll v0.9.1+5
  [8bb1440f] + DelimitedFiles
  [1a1011a3] + SharedArrays
  [8dfed614] + Test

(@v1.6) pkg> precompile
Precompiling project...
  ✗ Cairo_jll
  ✗ HarfBuzz_jll
  ✗ libass_jll
  ✗ FFMPEG_jll
  ✗ GR_jll
  ✗ Plots
  0 dependencies successfully precompiled in 38 seconds (147 already precompiled)

ERROR: The following 1 direct dependency failed to precompile:

Plots [91a5bcdd-55d7-5caf-9e0b-520d859cae80]

Failed to precompile Plots [91a5bcdd-55d7-5caf-9e0b-520d859cae80] to <home-directory>/.julia/compiled/v1.6/Plots/jl_RerNQU.
ERROR: LoadError: LoadError: InitError: could not load library "<home-directory>/.julia/artifacts/ddfc455343aff48d27c1b39d7fcb07e0d9242b50/lib/libpng16.so"
<cluster-system-path>/libraries/zlib/1.2.8/gnu--6.1.0/lib/libz.so.1: version `ZLIB_1.2.9' not found (required by <home-directory>/.julia/artifacts/ddfc455343aff48d27c1b39d7fcb07e0d9242b50/lib/libpng16.so)
Stacktrace:
  [1] dlopen(s::String, flags::UInt32; throw_error::Bool)
    @ Base.Libc.Libdl ./libdl.jl:114
  [2] dlopen(s::String, flags::UInt32)
    @ Base.Libc.Libdl ./libdl.jl:114
  [3] macro expansion
    @ ~/.julia/packages/JLLWrappers/bkwIo/src/products/library_generators.jl:54 [inlined]
  [4] __init__()
    @ libpng_jll ~/.julia/packages/libpng_jll/9vklf/src/wrappers/x86_64-linux-gnu.jl:9
  [5] _include_from_serialized(path::String, depmods::Vector{Any})
    @ Base ./loading.jl:696
  [6] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String)
    @ Base ./loading.jl:782
  [7] _require(pkg::Base.PkgId)
    @ Base ./loading.jl:1020
  [8] require(uuidkey::Base.PkgId)
    @ Base ./loading.jl:936
  [9] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:923
 [10] include(mod::Module, _path::String)
    @ Base ./Base.jl:386
 [11] top-level scope
    @ ~/.julia/packages/JLLWrappers/bkwIo/src/toplevel_generators.jl:170
 [12] include
    @ ./Base.jl:386 [inlined]
 [13] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
    @ Base ./loading.jl:1235
 [14] top-level scope
    @ none:1
 [15] eval
    @ ./boot.jl:360 [inlined]
 [16] eval(x::Expr)
    @ Base.MainInclude ./client.jl:446
 [17] top-level scope
    @ none:1
during initialization of module libpng_jll
in expression starting at <home-directory>/.julia/packages/Cairo_jll/zRgOn/src/wrappers/x86_64-linux-gnu.jl:6
in expression starting at <home-directory>/.julia/packages/Cairo_jll/zRgOn/src/Cairo_jll.jl:2
ERROR: LoadError: LoadError: Failed to precompile Cairo_jll [83423d85-b0ee-5818-9007-b63ccbeb887a] to <home-directory>/.julia/compiled/v1.6/Cairo_jll/jl_dpoEzd.
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:33
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IOContext{Base.PipeEndpoint}, internal_stdout::IOContext{IOStream}, ignore_loaded_modules::Bool)
    @ Base ./loading.jl:1385
  [3] compilecache(pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1329
  [4] _require(pkg::Base.PkgId)
    @ Base ./loading.jl:1043
  [5] require(uuidkey::Base.PkgId)
    @ Base ./loading.jl:936
  [6] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:923
  [7] include(mod::Module, _path::String)
    @ Base ./Base.jl:386
  [8] top-level scope
    @ ~/.julia/packages/JLLWrappers/bkwIo/src/toplevel_generators.jl:170
  [9] include
    @ ./Base.jl:386 [inlined]
 [10] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
    @ Base ./loading.jl:1235
 [11] top-level scope
    @ none:1
 [12] eval
    @ ./boot.jl:360 [inlined]
 [13] eval(x::Expr)
    @ Base.MainInclude ./client.jl:446
 [14] top-level scope
    @ none:1
in expression starting at <home-directory>/.julia/packages/HarfBuzz_jll/eogPK/src/wrappers/x86_64-linux-gnu.jl:4
in expression starting at <home-directory>/.julia/packages/HarfBuzz_jll/eogPK/src/HarfBuzz_jll.jl:2
ERROR: LoadError: LoadError: Failed to precompile HarfBuzz_jll [2e76f6c2-a576-52d4-95c1-20adfe4de566] to <home-directory>/.julia/compiled/v1.6/HarfBuzz_jll/jl_KpjxsY.
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:33
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IOContext{Base.PipeEndpoint}, internal_stdout::IOContext{IOStream}, ignore_loaded_modules::Bool)
    @ Base ./loading.jl:1385
  [3] compilecache(pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1329
  [4] _require(pkg::Base.PkgId)
    @ Base ./loading.jl:1043
  [5] require(uuidkey::Base.PkgId)
    @ Base ./loading.jl:936
  [6] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:923
  [7] include(mod::Module, _path::String)
    @ Base ./Base.jl:386
  [8] top-level scope
    @ ~/.julia/packages/JLLWrappers/bkwIo/src/toplevel_generators.jl:170
  [9] include
    @ ./Base.jl:386 [inlined]
 [10] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
    @ Base ./loading.jl:1235
 [11] top-level scope
    @ none:1
 [12] eval
    @ ./boot.jl:360 [inlined]
 [13] eval(x::Expr)
    @ Base.MainInclude ./client.jl:446
 [14] top-level scope
    @ none:1
in expression starting at <home-directory>/.julia/packages/libass_jll/SaaQW/src/wrappers/x86_64-linux-gnu.jl:6
in expression starting at <home-directory>/.julia/packages/libass_jll/SaaQW/src/libass_jll.jl:2
ERROR: LoadError: LoadError: Failed to precompile libass_jll [0ac62f75-1d6f-5e53-bd7c-93b484bb37c0] to <home-directory>/.julia/compiled/v1.6/libass_jll/jl_TWRThR.
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:33
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IOContext{Base.PipeEndpoint}, internal_stdout::IOContext{IOStream}, ignore_loaded_modules::Bool)
    @ Base ./loading.jl:1385
  [3] compilecache(pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1329
  [4] _require(pkg::Base.PkgId)
    @ Base ./loading.jl:1043
  [5] require(uuidkey::Base.PkgId)
    @ Base ./loading.jl:936
  [6] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:923
  [7] include(mod::Module, _path::String)
    @ Base ./Base.jl:386
  [8] top-level scope
    @ ~/.julia/packages/JLLWrappers/bkwIo/src/toplevel_generators.jl:170
  [9] include
    @ ./Base.jl:386 [inlined]
 [10] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
    @ Base ./loading.jl:1235
 [11] top-level scope
    @ none:1
 [12] eval
    @ ./boot.jl:360 [inlined]
 [13] eval(x::Expr)
    @ Base.MainInclude ./client.jl:446
 [14] top-level scope
    @ none:1
in expression starting at <home-directory>/.julia/packages/FFMPEG_jll/ECokx/src/wrappers/x86_64-linux-gnu.jl:4
in expression starting at <home-directory>/.julia/packages/FFMPEG_jll/ECokx/src/FFMPEG_jll.jl:2
ERROR: LoadError: Failed to precompile FFMPEG_jll [b22a6f82-2f65-5046-a5b2-351ab43fb4e5] to <home-directory>/.julia/compiled/v1.6/FFMPEG_jll/jl_6VTcXq.
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:33
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IOContext{Base.PipeEndpoint}, internal_stdout::IOContext{IOStream}, ignore_loaded_modules::Bool)
    @ Base ./loading.jl:1385
  [3] compilecache(pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1329
  [4] _require(pkg::Base.PkgId)
    @ Base ./loading.jl:1043
  [5] require(uuidkey::Base.PkgId)
    @ Base ./loading.jl:936
  [6] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:923
  [7] include
    @ ./Base.jl:386 [inlined]
  [8] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
    @ Base ./loading.jl:1235
  [9] top-level scope
    @ none:1
 [10] eval
    @ ./boot.jl:360 [inlined]
 [11] eval(x::Expr)
    @ Base.MainInclude ./client.jl:446
 [12] top-level scope
    @ none:1
in expression starting at <home-directory>/.julia/packages/FFMPEG/OUpap/src/FFMPEG.jl:1
ERROR: LoadError: Failed to precompile FFMPEG [c87230d0-a227-11e9-1b43-d7ebe4e7570a] to <home-directory>/.julia/compiled/v1.6/FFMPEG/jl_xNc0xN.
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:33
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IOContext{Base.PipeEndpoint}, internal_stdout::IOContext{IOStream}, ignore_loaded_modules::Bool)
    @ Base ./loading.jl:1385
  [3] compilecache(pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1329
  [4] _require(pkg::Base.PkgId)
    @ Base ./loading.jl:1043
  [5] require(uuidkey::Base.PkgId)
    @ Base ./loading.jl:936
  [6] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:923
  [7] include
    @ ./Base.jl:386 [inlined]
  [8] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
    @ Base ./loading.jl:1235
  [9] top-level scope
    @ none:1
 [10] eval
    @ ./boot.jl:360 [inlined]
 [11] eval(x::Expr)
    @ Base.MainInclude ./client.jl:446
 [12] top-level scope
    @ none:1
in expression starting at <home-directory>/.julia/packages/Plots/1RWWg/src/Plots.jl:1

(@v1.6) pkg> 

My educated guess is that you have the environment variable LD_LIBRARY_PATH set to some value which is messing up with julia. Try to start Julia with

LD_LIBRARY_PATH="" julia

I had a similar zlib linkage problem building a docker container recently, and setting LD_LIBRARY_PATH to include julia’s lib directory first fixed it.

Thanks both! @giordano’s reply fixed the problem for me. As a long-term solution, I’ve added a line to my .julia/config/startup.jl

ENV["LD_LIBRARY_PATH"] = ""