Failed to install Plots.jl LoadError on Arch Linux

I am unable to install Plots.jl on Arch Linux with julia version 1.6.2.

Output of ]status

      Status `~/.julia/environments/v1.6/Project.toml`
  [0c46a032] DifferentialEquations v6.17.2
  [634d3b9d] DrWatson v2.1.0
  [28b8d3ca] GR v0.58.0
  [7073ff75] IJulia v1.23.2
  [eff96d63] Measurements v2.6.0
  [d330b81b] PyPlot v2.9.0
  [b22a6f82] FFMPEG_jll v4.3.1+4

After ]add Plots and precompile, I get the following error

Precompiling project...
  ✗ FFMPEG
  ✗ GR_jll
  ✗ Plots
  0 dependencies successfully precompiled in 4 seconds (227 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/oponkork/.julia/compiled/v1.6/Plots/jl_I2k2pA.
ERROR: LoadError: InitError: could not load library "/home/oponkork/.julia/artifacts/7f40eeb66d90d3026ae5fb68761c263b57adb840/lib/libavdevice.so"
/usr/lib/libavformat.so.58: undefined symbol: avpriv_packet_list_free, version LIBAVCODEC_58
Stacktrace:
 [1] dlopen(s::String, flags::UInt32)
   @ Base.Libc.Libdl ./libdl.jl:114
 [2] macro expansion
   @ ~/.julia/packages/JLLWrappers/bkwIo/src/products/library_generators.jl:54 [inlined]
 [3] __init__()
   @ FFMPEG_jll ~/.julia/packages/FFMPEG_jll/xCSqL/src/wrappers/x86_64-linux-gnu.jl:47
 [4] top-level scope (repeats 2 times)
   @ none:1
during initialization of module FFMPEG_jll
in expression starting at /home/oponkork/.julia/packages/FFMPEG/OUpap/src/FFMPEG.jl:1
ERROR: LoadError: Failed to precompile FFMPEG [c87230d0-a227-11e9-1b43-d7ebe4e7570a] to /home/oponkork/.julia/compiled/v1.6/FFMPEG/jl_GgCh6S.
Stacktrace:
 [1] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IOContext{Base.PipeEndpoint}, internal_stdout::IOContext{IOStream}, ignore_loaded_modules::Bool)
   @ Base ./loading.jl:1385
 [2] top-level scope (repeats 2 times)
   @ none:1
in expression starting at /home/oponkork/.julia/packages/Plots/S2aH5/src/Plots.jl:1

/home/oponkork/.julia/artifacts/7f40eeb66d90d3026ae5fb68761c263b57adb840/lib/libavdevice.so should be looking for /home/oponkork/.julia/artifacts/7f40eeb66d90d3026ae5fb68761c263b57adb840/lib/libavformat.so

Something is causing libavdevice.so to load your system library rather than the one in FFMPEG_jll. Do you have a LD_LIBRARY_PATH or LD_PRELOAD in your environmental variables?

I do set LD_LIBRARY_PATH=/usr/lib:/usr/lib64:. How do I fix the issue?

Okay, I tried ENV["LD_LIBRARY_PATH"] = "" in the julia repl and then precompiled and it worked. Is this the correct approach?

That works, but I recommend investigating why LD_LIBRARY_PATH is set in the first place. Is it in your .bash_profile or .bashrc or something like that?

did you install julia via pacman? please use julia-bin from AUR or directly download binary yourself from julialang.org

I set it myself, do not remember why but needed it at some point in the past. Maybe I will remove it and see if anything else breaks.

Yes. I installed it via pacman. Is there a reason to pick up AUR package over the pacman one?

the reason is linux distro maintainers don’t care about Julia they only care if Julia compiles with their libraries. Better use ready-made binary Julia, either manually, or use AUR which is the same thing except it will update later.

1 Like