Plots, InitError: UndefVarError: GR_jll not defined

A persistent error such as this may require the following command to force GR to recompile.

Base.compilecache(Base.identify_package("GR"))

This situation occurs due to some initial problem with loading GR_jll on this line:

However, due to the surrounding try-catch the problem is ignored and compilation continues. Once the compilation succeeds, the issue may persist if Julia fails to recognize the need to invalidate the compile cache for GR.

If the above does not resolve the issue, first assess if there is a problem loading GR_jll with the following steps in a fresh Julia session (restart Julia):

using Pkg
Pkg.activate(; temp = true)
Pkg.add("GR_jll")
import GR_jll

If that succeeds, then try the following.

Pkg.add("GR")
Base.compilecache(Base.identify_package("GR"))
using GR
GR.plot(rand(10))

If GR function works, then try adding Plots.jl

Pkg.add("Plots")
using Plots
Plots.plot(rand(10))

An alternate approach to using Base.compilecache would be to manually locate the files in ~/.julia/compiled/v1.9 for GR and remove them.

8 Likes