`using Plots` errors (`ERROR: LoadError: InitError: UndefVarError: `GR_jll` not defined`)

Yesterday I was helping a friend instal Julia. It was a mac computer, and we installed Julia from scratch using juliaup. We added a like 4 packages, including Plots. When we tried

using Plots

we got an error (see end).

I tried for a really long time to figure out what went wrong, trying on both Julia version 1.10.2 and 1.10.3. Tried restarting Julia and the computer. All various Pkg command (instantiate, resolve, build, update etc.). I tried installing and/or building GR directly (same issue when running using GR). I also did some searching and e.g. all the things that went on here: Plots, InitError: UndefVarError: GR_jll not defined - #3 by mkitti. I am really confused only. We didn’t do anything strange and I see no reason this should be able to fail.

My friend left last night (short visit only) and will probably just go back to Matlab. However, given the really mundane situation (I bet tons of people are using Plots.jl…) it seems like many people have this issue. Hence, I figured I’d raise an issue, in case someone knows how to solve it, that ways others might get help when they search for it.

julia> using Plots
Precompiling Plots
        Info Given Plots was explicitly requested, output will be shown live 
ERROR: LoadError: InitError: UndefVarError: `GR_jll` not defined
Stacktrace:
  [1] __init__()
    @ GR.GRPreferences ~/.julia/packages/GR/SdanO/src/preferences.jl:64
  [2] run_module_init(mod::Module, i::Int64)
    @ Base ./loading.jl:1134
  [3] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1122
  [4] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any})
    @ Base ./loading.jl:1067
  [5] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
    @ Base ./loading.jl:1581
  [6] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:1938
  [7] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1812
  [8] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
  [9] invoke_in_world
    @ ./essentials.jl:923 [inlined]
 [10] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1803
 [11] macro expansion
    @ ./loading.jl:1790 [inlined]
 [12] macro expansion
    @ ./lock.jl:267 [inlined]
 [13] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1753
 [14] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
 [15] invoke_in_world
    @ ./essentials.jl:923 [inlined]
 [16] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1746
 [17] top-level scope
    @ ~/.julia/packages/Plots/ju9dp/src/backends.jl:380
 [18] eval
    @ ./boot.jl:385 [inlined]
 [19] _initialize_backend(pkg::Plots.GRBackend)
    @ Plots ~/.julia/packages/Plots/ju9dp/src/backends.jl:379
 [20] backend(pkg::Plots.GRBackend)
    @ Plots ~/.julia/packages/Plots/ju9dp/src/backends.jl:244
 [21] backend(sym::Symbol)
    @ Plots ~/.julia/packages/Plots/ju9dp/src/backends.jl:254
 [22] load_default_backend()
    @ Plots ~/.julia/packages/Plots/ju9dp/src/backends.jl:201
 [23] backend()
    @ Plots ~/.julia/packages/Plots/ju9dp/src/backends.jl:232
 [24] top-level scope
    @ ~/.julia/packages/Plots/ju9dp/src/init.jl:108
 [25] include(mod::Module, _path::String)
    @ Base ./Base.jl:495
 [26] include(x::String)
    @ Plots ~/.julia/packages/Plots/ju9dp/src/Plots.jl:1
 [27] top-level scope
    @ ~/.julia/packages/Plots/ju9dp/src/Plots.jl:176
 [28] include
    @ ./Base.jl:495 [inlined]
 [29] 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, UInt128}}, source::Nothing)
    @ Base ./loading.jl:2222
 [30] top-level scope
    @ stdin:3
during initialization of module GRPreferences
in expression starting at /Users/chris/.julia/packages/Plots/ju9dp/src/init.jl:108
in expression starting at /Users/chris/.julia/packages/Plots/ju9dp/src/Plots.jl:1
in expression starting at stdin:3
  ✗ GR_jll
  ✗ Plots
  ✗ Plots → UnitfulExt
  0 dependencies successfully precompiled in 18 seconds. 154 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 "/Users/chris/.julia/compiled/v1.10/Plots/jl_b4mlJe".
ERROR: LoadError: InitError: UndefVarError: `GR_jll` not defined
Stacktrace:
  [1] __init__()
    @ GR.GRPreferences ~/.julia/packages/GR/SdanO/src/preferences.jl:64
  [2] run_module_init(mod::Module, i::Int64)
    @ Base ./loading.jl:1134
  [3] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1122
  [4] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any})
    @ Base ./loading.jl:1067
  [5] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
    @ Base ./loading.jl:1581
  [6] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:1938
  [7] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1812
  [8] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
  [9] invoke_in_world
    @ ./essentials.jl:923 [inlined]
 [10] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1803
 [11] macro expansion
    @ ./loading.jl:1790 [inlined]
 [12] macro expansion
    @ ./lock.jl:267 [inlined]
 [13] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1753
 [14] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
 [15] invoke_in_world
    @ ./essentials.jl:923 [inlined]
 [16] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1746
 [17] top-level scope
    @ ~/.julia/packages/Plots/ju9dp/src/backends.jl:380
 [18] eval
    @ ./boot.jl:385 [inlined]
 [19] _initialize_backend(pkg::Plots.GRBackend)
    @ Plots ~/.julia/packages/Plots/ju9dp/src/backends.jl:379
 [20] backend(pkg::Plots.GRBackend)
    @ Plots ~/.julia/packages/Plots/ju9dp/src/backends.jl:244
 [21] backend(sym::Symbol)
    @ Plots ~/.julia/packages/Plots/ju9dp/src/backends.jl:254
 [22] load_default_backend()
    @ Plots ~/.julia/packages/Plots/ju9dp/src/backends.jl:201
 [23] backend()
    @ Plots ~/.julia/packages/Plots/ju9dp/src/backends.jl:232
 [24] top-level scope
    @ ~/.julia/packages/Plots/ju9dp/src/init.jl:108
 [25] include(mod::Module, _path::String)
    @ Base ./Base.jl:495
 [26] include(x::String)
    @ Plots ~/.julia/packages/Plots/ju9dp/src/Plots.jl:1
 [27] top-level scope
    @ ~/.julia/packages/Plots/ju9dp/src/Plots.jl:176
 [28] include
    @ ./Base.jl:495 [inlined]
 [29] 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, UInt128}}, source::Nothing)
    @ Base ./loading.jl:2222
 [30] top-level scope
    @ stdin:3
during initialization of module GRPreferences
in expression starting at /Users/chris/.julia/packages/Plots/ju9dp/src/init.jl:108
in expression starting at /Users/chris/.julia/packages/Plots/ju9dp/src/Plots.jl:1
in expression starting at stdin:
Stacktrace:
  [1] pkgerror(msg::String)
    @ Pkg.Types ~/.julia/juliaup/julia-1.10.2+0.x64.apple.darwin14/share/julia/stdlib/v1.10/Pkg/src/Types.jl:70
  [2] precompile(ctx::Pkg.Types.Context, pkgs::Vector{…}; internal_call::Bool, strict::Bool, warn_loaded::Bool, already_instantiated::Bool, timing::Bool, _from_loading::Bool, kwargs::@Kwargs{…})
    @ Pkg.API ~/.julia/juliaup/julia-1.10.2+0.x64.apple.darwin14/share/julia/stdlib/v1.10/Pkg/src/API.jl:1659
  [3] precompile(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::@Kwargs{_from_loading::Bool})
    @ Pkg.API ~/.julia/juliaup/julia-1.10.2+0.x64.apple.darwin14/share/julia/stdlib/v1.10/Pkg/src/API.jl:159
  [4] precompile
    @ ~/.julia/juliaup/julia-1.10.2+0.x64.apple.darwin14/share/julia/stdlib/v1.10/Pkg/src/API.jl:147 [inlined]
  [5] #precompile#114
    @ ~/.julia/juliaup/julia-1.10.2+0.x64.apple.darwin14/share/julia/stdlib/v1.10/Pkg/src/API.jl:146 [inlined]
  [6] #invokelatest#2
    @ ./essentials.jl:894 [inlined]
  [7] invokelatest
    @ ./essentials.jl:889 [inlined]
  [8] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:1963
  [9] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1812
 [10] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
 [11] invoke_in_world
    @ ./essentials.jl:923 [inlined]
 [12] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1803
 [13] macro expansion
    @ ./loading.jl:1790 [inlined]
 [14] macro expansion
    @ ./lock.jl:267 [inlined]
 [15] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1753
 [16] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
 [17] invoke_in_world
    @ ./essentials.jl:923 [inlined]
 [18] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1746
 [19] eval
    @ ./boot.jl:385 [inlined]
 [20] eval
    @ ./Base.jl:88 [inlined]
 [21] repleval(m::Module, code::Expr, ::String)
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.76.2/scripts/packages/VSCodeServer/src/repl.jl:229
 [22] (::VSCodeServer.var"#112#114"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.76.2/scripts/packages/VSCodeServer/src/repl.jl:192
 [23] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging ./logging.jl:515
 [24] with_logger
    @ ./logging.jl:627 [inlined]
 [25] (::VSCodeServer.var"#111#113"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.76.2/scripts/packages/VSCodeServer/src/repl.jl:193
 [26] #invokelatest#2
    @ ./essentials.jl:892 [inlined]
 [27] invokelatest(::Any)
    @ Base ./essentials.jl:889
 [28] (::VSCodeServer.var"#64#65")()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.76.2/scripts/packages/VSCodeServer/src/eval.jl:34
Some type information was truncated. Use `show(err)` to see complete types.

Did you try these specific instructions that I posted yesterday?

using Pkg
# skip activation of a temp environment if you are trying to fix your environment
Pkg.activate(; temp=true)
# Add LERC_jll version 3
Pkg.add([
    PackageSpec(name="GR"),
    PackageSpec(name="LERC_jll", version="3")
])
# Force GR to precompile
Base.compilecache(Base.PkgId(Base.UUID("28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71"), "GR"))

There was package, LERC_jll which contained a binary neeed by libtiff which is need by GR which is needed by plots. A few days ago that library was updated to version 4 form version 3. It turns out libtiff is not compatible with version 4 which started the failure cascade.

I should also mention that perhaps Plots.jl should not be the first plotting package you reach for, although I understand why that might seem like the most obvious choice. As you can see above it has a a lot of external dependencies.

I generally reach for Makie.jl first, specifically the GLMakie.jl backend.

1 Like

I did not try the PackageSpec(name="LERC_jll", version="3"), yeah, that might work.

Here’s the timeline (time are EDT):

The issue was identified and a workaround became available in 2.5 hours. By my estimate there was a 4 - 5 hour window where this issue could have been encountered. It unfortunately corresponded with the 1.10.3 release when many people were also updating.

I think there might be some room for some CI improvements, and perhaps some extra special attention for Plots.jl. That said I’m overall impressed with the response.

Perhaps my only suggestion is to raise an issue earlier rather than later.

4 Likes

Sounds like we were unlucky, things happen.

I’ve had problems with using Plots crashing quite a few times before (I think Pkg.build("Plots") has been the usual solution, and thought that this might have been a related (but more sever case) of something that’s been around for a while. Seems it was unrelated though.