"LoadError: InitError: Evaluation into the closed module `GR` breaks incremental compilation..."

I installed Plots with the gr() back end several weeks ago, and it had been working fine up until today. I shutdown the kernel yesterday evening after I was done working on my Jupyter notebook, and when I restarted it today and attempted to compile Plots; gr(), along with my other packages, I got the following error:

┌ Info: Precompiling Plots [91a5bcdd-55d7-5caf-9e0b-520d859cae80]
└ @ Base loading.jl:1278

Your GR installation is incomplete. Rerun build step for GR package.

ERROR: LoadError: LoadError: InitError: Evaluation into the closed module `GR` breaks incremental compilation because the side effects will not be permanent. This is likely due to some other module mutating `GR` with `eval` during precompilation - don't do this.
Stacktrace:
 [1] eval at .\boot.jl:331 [inlined]
 [2] __init__() at C:\Users\Michael\.julia\packages\GR\RlE5Y\src\GR.jl:274
 [3] _include_from_serialized(::String, ::Array{Any,1}) at .\loading.jl:697
 [4] _require_search_from_serialized(::Base.PkgId, ::String) at .\loading.jl:782
 [5] _require(::Base.PkgId) at .\loading.jl:1007
 [6] require(::Base.PkgId) at .\loading.jl:928
 [7] require(::Module, ::Symbol) at .\loading.jl:923
 [8] include(::Function, ::Module, ::String) at .\Base.jl:380
 [9] include at .\Base.jl:368 [inlined]
 [10] include(::String) at C:\Users\Michael\.julia\packages\Plots\lmp2A\src\Plots.jl:1
 [11] top-level scope at C:\Users\Michael\.julia\packages\Plots\lmp2A\src\Plots.jl:212
 [12] include(::Function, ::Module, ::String) at .\Base.jl:380
 [13] include(::Module, ::String) at .\Base.jl:368
 [14] top-level scope at none:2
 [15] eval at .\boot.jl:331 [inlined]
 [16] eval(::Expr) at .\client.jl:467
 [17] top-level scope at .\none:3
during initialization of module GR
in expression starting at C:\Users\Michael\.julia\packages\Plots\lmp2A\src\backends\gr.jl:6
in expression starting at C:\Users\Michael\.julia\packages\Plots\lmp2A\src\Plots.jl:212

I have no idea what’s going on here. I tried uninstalling and then reinstalling Plots using Pkg.rm("Plots"), followed by Pkg.add("Plots") and Pkg.add("GR"), but I got the same error again when I attempted to precompile. Does anyone know what’s causing this issue/how to fix it?

In case it matters, here are all of the packages I was trying to compile (plus two notebooks I was importing):

using Pkg
using Plots; gr()
using XLSX
using Dates
using DataFrames
using DifferentialEquations
using Statistics
using Random
using ForwardDiff
using NLopt
using LinearAlgebra
using Optim
using NBInclude
using Printf
@nbinclude("ODE_models.ipynb")
@nbinclude("Norm_functions.ipynb")
1 Like

Have you tried ]build Plots as the error message suggests? What happens?

Also note that you don’t have to explicitly ]add GR as a package or call gr() when using Plots, GR is the default backend so will be installed upon installation of Plots and activated once you use Plots.

7 Likes

Thanks, ]build Plots did it! That was an easy fix!

And good to know about gr().

I had the same problem.
Rebuilding Plots and GR did not help.
I needed to set a fresh depot with JULIA_DEPOT_PATH=/some/path

Interesting…glad you found a solution.

Rebuilding Plots and GR did not help me either.

Apparently, I have three depot paths:

julia> DEPOT_PATH
3-element Vector{String}:
 "/home/timothy/.julia"
 "/home/timothy/julia-1.6.0/local/share/julia"
 "/home/timothy/julia-1.6.0/share/julia"

The two paths:

/home/timothy/.julia
and
/home/timothy/julia-1.6.0/share/julia

exist, but:
/home/timothy/julia-1.6.0/local/share/julia
does not.

I am unsure of exactly how I should proceed.

Should I delete
/home/timothy/julia-1.6.0/local/share/julia
from the depot path array? And if so, do you know where and how I do that?

This is how I set a fresh depot:

JULIA_DEPOT_PATH=~/.julia/julia-1.6.0_depot julia

Where I make sure ~/.julia/julia-1.6.0_depot exists.

Then that is the one being used:

julia> DEPOT_PATH
1-element Vector{String}:
 "~/.julia/julia-1.6.0_depot"

With two pop!()s and a push!() in the REPL, I had fixed my DEPOT_PATH to have only the two existing paths:

julia> DEPOT_PATH
2-element Vector{String}:
 "/home/timothy/.julia"
 "/home/timothy/julia-1.6.0/share/julia"

But had still received the "Your GR installation is incomplete." message.

So you had first created a new file and then set JULIA_DEPOT_PATH somewhere other than the REPL?

If nothing else works, I will consider completely reinstalling Julia.

Hi @Tim_G

I start julia from the commandline (Ubuntu/Linux).

So in a shell I create the folder:

$ mkdir  ~/.julia/julia-1.6.0_depot

Then I start julia from a shell:

$ JULIA_DEPOT_PATH=~/.julia/julia-1.6.0_depot julia

You can also do it in 2 lines by “exporting” the environment variable.
In bash I do:

$ export  JULIA_DEPOT_PATH="~/.julia/julia-1.6.0_depot"
$ julia
1 Like

Thank you for your time and for introducing me to Julia’s environment variables. I will have to look into them more. I encountered some other compilation issue when trying to launch a Pluto notebook using Plots.jl (sorry to say I cannot recall the exact details). What worked for me, after reading ChunXi Zhang’s post was deleting what was in the ~.julia\compiled\v1.6\GR file.

I got the same error after updating all my packages. I didn’t try the “fresh depot approach” but removed Plots and reinstalled v1.6.11 using ] add Plots@1.6.11
Now everything works as before

Thank you! “add Plots@1.6.11” did the trick for me with Julia 1.5.1

This finally worked for me.

what was happening here? I see people have had this issue on & off for three years. Where does this have to be “fixed” in order for the issue to not occur again?

thanks