# Cannot Precompile Plots.jl due to GR

**URL:** https://discourse.julialang.org/t/cannot-precompile-plots-jl-due-to-gr/88230
**Category:** General Usage
**Created:** [October 4, 2022, 1:27pm UTC](https://discourse.julialang.org/t/cannot-precompile-plots-jl-due-to-gr/88230 "2022-10-04T13:27:25Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![SpinolaHours](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@SpinolaHours](https://discourse.julialang.org/u/SpinolaHours)
#### Post date: [October 4, 2022, 1:27pm UTC](https://discourse.julialang.org/t/cannot-precompile-plots-jl-due-to-gr/88230/1 "2022-10-04T13:27:25Z")

</div>

Hi there,

I recently upgraded to 1.8.0. At some point I lost the ability to precompile plots due to a GR\_jll error. I see other people have had similar issues and have tried the following with no luck:

- Removing .julia
- Building GR again
- Setting ENV[“GRDIR”] = “”

The only solution I have found to work is downgrading the GR.jl package. Otherwise I get the following error:  
ERROR: LoadError: InitError: UndefVarError: GR\_jll not defined

Can anyone explain why this is the case? I’d rather not have to downgrade any of my packages.

FYI I’m on a linux machine.

---

<div class="post-metadata">

### Author: ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)
#### Post date: [October 4, 2022, 1:58pm UTC](https://discourse.julialang.org/t/cannot-precompile-plots-jl-due-to-gr/88230/2 "2022-10-04T13:58:01Z")

</div>

what versions of packages do you have?

---

<div class="post-metadata">

### Author: ![SpinolaHours](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@SpinolaHours](https://discourse.julialang.org/u/SpinolaHours)
#### Post date: [October 4, 2022, 2:39pm UTC](https://discourse.julialang.org/t/cannot-precompile-plots-jl-due-to-gr/88230/3 "2022-10-04T14:39:11Z")

</div>

(@v1.8) pkg\> status  
Status `~/.julia/environments/v1.8/Project.toml`  
[336ed68f] CSV v0.10.4  
[82f2e89e] ClickHouse v0.2.2  
[1313f7d8] DataFramesMeta v0.12.0  
[28b8d3ca] GR v0.69.3  
[91a5bcdd] Plots v1.35.2

---

<div class="post-metadata">

### Author: ![t-bltg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/t-bltg/32/25526_2.png) [@t-bltg](https://discourse.julialang.org/u/t-bltg)
#### Post date: [October 4, 2022, 2:42pm UTC](https://discourse.julialang.org/t/cannot-precompile-plots-jl-due-to-gr/88230/4 "2022-10-04T14:42:53Z")

</div>

Can you output the whole stacktrace ? We’ve had some issues with `window` or `macOS` recently, but none on `linux`.

Is your `julia` an official release ([Download Julia](https://julialang.org/downloads/)) of a build of your distro ?

---

<div class="post-metadata">

### Author: ![SpinolaHours](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@SpinolaHours](https://discourse.julialang.org/u/SpinolaHours)
#### Post date: [October 4, 2022, 2:44pm UTC](https://discourse.julialang.org/t/cannot-precompile-plots-jl-due-to-gr/88230/5 "2022-10-04T14:44:55Z")

</div>

ERROR: LoadError: InitError: UndefVarError: GR\_jll not defined  
Stacktrace:  
[1] **init** ()  
@ GR.GRPreferences ~/.julia/packages/GR/Wz6ek/src/preferences.jl:40  
[2] \_include\_from\_serialized(pkg::Base.PkgId, path::String, depmods::Vector{Any})  
@ Base ./loading.jl:831  
[3] \_require\_search\_from\_serialized(pkg::Base.PkgId, sourcepath::String, build\_id::UInt64)  
@ Base ./loading.jl:1039  
[4] \_require(pkg::Base.PkgId)  
@ Base ./loading.jl:1315  
[5] \_require\_prelocked(uuidkey::Base.PkgId)  
@ Base ./loading.jl:1200  
[6] macro expansion  
@ ./loading.jl:1180 [inlined]  
[7] macro expansion  
@ ./lock.jl:223 [inlined]  
[8] require(into::Module, mod::Symbol)  
@ Base ./loading.jl:1144  
[9] include(mod::Module, \_path::String)  
@ Base ./Base.jl:419  
[10] include(x::String)  
@ Plots ~/.julia/packages/Plots/CUQan/src/Plots.jl:1  
[11] top-level scope  
@ ~/.julia/packages/Plots/CUQan/src/Plots.jl:201  
[12] include  
@ ./Base.jl:419 [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::Nothing)  
@ Base ./loading.jl:1554  
[14] top-level scope  
@ stdin:1  
during initialization of module GRPreferences  
in expression starting at /home/jcooper/.julia/packages/Plots/CUQan/src/backends/gr.jl:3  
in expression starting at /home/jcooper/.julia/packages/Plots/CUQan/src/Plots.jl:1  
in expression starting at stdin:1  
ERROR: Failed to precompile Plots [91a5bcdd-55d7-5caf-9e0b-520d859cae80] to /home/jcooper/.julia/compiled/v1.8/Plots/jl\_hLRsn0.  
Stacktrace:  
[1] error(s::String)  
@ Base ./error.jl:35  
[2] compilecache(pkg::Base.PkgId, path::String, internal\_stderr::IO, internal\_stdout::IO, keep\_loaded\_modules::Bool)  
@ Base ./loading.jl:1705  
[3] compilecache  
@ ./loading.jl:1649 [inlined]  
[4] \_require(pkg::Base.PkgId)  
@ Base ./loading.jl:1337  
[5] \_require\_prelocked(uuidkey::Base.PkgId)  
@ Base ./loading.jl:1200  
[6] macro expansion  
@ ./loading.jl:1180 [inlined]  
[7] macro expansion  
@ ./lock.jl:223 [inlined]  
[8] require(into::Module, mod::Symbol)  
@ Base ./loading.jl:1144

---

<div class="post-metadata">

### Author: ![SpinolaHours](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@SpinolaHours](https://discourse.julialang.org/u/SpinolaHours)
#### Post date: [October 4, 2022, 2:45pm UTC](https://discourse.julialang.org/t/cannot-precompile-plots-jl-due-to-gr/88230/6 "2022-10-04T14:45:40Z")

</div>

Yes. It is a tar.gz download from official julia website.

---

<div class="post-metadata">

### Author: ![t-bltg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/t-bltg/32/25526_2.png) [@t-bltg](https://discourse.julialang.org/u/t-bltg)
#### Post date: [October 4, 2022, 2:47pm UTC](https://discourse.julialang.org/t/cannot-precompile-plots-jl-due-to-gr/88230/7 "2022-10-04T14:47:20Z")

</div>

Thanks, now can set the environment variable `JULIA_DEBUG` to `GR` before starting julia ?

```bash
$ JULIA_DEBUG=GR julia
julia> using Plots
┌ Debug: import GR_jll failed
│ err = [...]
└ @ GR.GRPreferences [...]/GR.jl/src/preferences.jl:7

```

and post the output ?

Alternatively you can do this from within julia:

```julia
julia> ENV["JULIA_DEBUG"] = "GR";
julia> using Plots
[...]

```

It should trigger [GR.jl/preferences.jl at ce153a2626413668d0387d6ff62008e2dc3fbf55 · jheinen/GR.jl · GitHub](https://github.com/jheinen/GR.jl/blob/ce153a2626413668d0387d6ff62008e2dc3fbf55/src/preferences.jl#L6).

---

<div class="post-metadata">

### Author: ![sjkelly](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sjkelly/32/9280_2.png) [@sjkelly](https://discourse.julialang.org/u/sjkelly)
#### Post date: [October 4, 2022, 2:53pm UTC](https://discourse.julialang.org/t/cannot-precompile-plots-jl-due-to-gr/88230/8 "2022-10-04T14:53:02Z")

</div>

With the latest releases of Plots (1.35) and GR (0.69), you should not need to explicitly call out GR in the Project.toml. You should be able to `] rm GR`, then `] up` in Pkg mode without the need to `build GR` or anything like that. This is due to the transition to artifacts in GR to allow more extensive precompilation.

---

<div class="post-metadata">

### Author: ![SpinolaHours](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@SpinolaHours](https://discourse.julialang.org/u/SpinolaHours)
#### Post date: [October 5, 2022, 11:03am UTC](https://discourse.julialang.org/t/cannot-precompile-plots-jl-due-to-gr/88230/9 "2022-10-05T11:03:26Z")

</div>

With debug enabled:

julia\>  
(base) [jcooper@hkquant01 v1.8]$ JULIA\_DEBUG=GR julia  
\_  
\_ \_ _(_)\_ | Documentation: [https://docs.julialang.org](https://docs.julialang.org)  
(_) | (_) (_) |  
\_ \_ | | \_\_ \_ | Type “?” for help, “]?” for Pkg help.  
| | | | | | |/ ` | |  
| | || | | | (_| | | Version 1.8.0 (2022-08-17)  
_/ |\ __‘_|_|_|\__ ’\_| | Official [https://julialang.org/](https://julialang.org/) release  
|\_\_/ |

julia\> using Plots  
[Info: Precompiling Plots [91a5bcdd-55d7-5caf-9e0b-520d859cae80]  
ERROR: LoadError: InitError: UndefVarError: GR\_jll not defined  
Stacktrace:  
[1] **init** ()  
@ GR.GRPreferences ~/.julia/packages/GR/Wz6ek/src/preferences.jl:40  
[2] \_include\_from\_serialized(pkg::Base.PkgId, path::String, depmods::Vector{Any})  
@ Base ./loading.jl:831  
[3] \_require\_search\_from\_serialized(pkg::Base.PkgId, sourcepath::String, build\_id::UInt64)  
@ Base ./loading.jl:1039  
[4] \_require(pkg::Base.PkgId)  
@ Base ./loading.jl:1315  
[5] \_require\_prelocked(uuidkey::Base.PkgId)  
@ Base ./loading.jl:1200  
[6] macro expansion  
@ ./loading.jl:1180 [inlined]  
[7] macro expansion  
@ ./lock.jl:223 [inlined]  
[8] require(into::Module, mod::Symbol)  
@ Base ./loading.jl:1144  
[9] include(mod::Module, \_path::String)  
@ Base ./Base.jl:419  
[10] include(x::String)  
@ Plots ~/.julia/packages/Plots/CUQan/src/Plots.jl:1  
[11] top-level scope  
@ ~/.julia/packages/Plots/CUQan/src/Plots.jl:201  
[12] include  
@ ./Base.jl:419 [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::Nothing)  
@ Base ./loading.jl:1554  
[14] top-level scope  
@ stdin:1  
during initialization of module GRPreferences  
in expression starting at /home/jcooper/.julia/packages/Plots/CUQan/src/backends/gr.jl:3  
in expression starting at /home/jcooper/.julia/packages/Plots/CUQan/src/Plots.jl:1  
in expression starting at stdin:1  
ERROR: Failed to precompile Plots [91a5bcdd-55d7-5caf-9e0b-520d859cae80] to /home/jcooper/.julia/compiled/v1.8/Plots/jl\_1BdlLv.  
Stacktrace:  
[1] error(s::String)  
@ Base ./error.jl:35  
[2] compilecache(pkg::Base.PkgId, path::String, internal\_stderr::IO, internal\_stdout::IO, keep\_loaded\_modules::Bool)  
@ Base ./loading.jl:1705  
[3] compilecache  
@ ./loading.jl:1649 [inlined]  
[4] \_require(pkg::Base.PkgId)  
@ Base ./loading.jl:1337  
[5] \_require\_prelocked(uuidkey::Base.PkgId)  
@ Base ./loading.jl:1200  
[6] macro expansion  
@ ./loading.jl:1180 [inlined]  
[7] macro expansion  
@ ./lock.jl:223 [inlined]  
[8] require(into::Module, mod::Symbol)  
@ Base ./loading.jl:1144

Not sure the debug has been triggered properly?

---

<div class="post-metadata">

### Author: ![SpinolaHours](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@SpinolaHours](https://discourse.julialang.org/u/SpinolaHours)
#### Post date: [October 5, 2022, 11:06am UTC](https://discourse.julialang.org/t/cannot-precompile-plots-jl-due-to-gr/88230/10 "2022-10-05T11:06:22Z")

</div>

I get the same error regardless of whether I explicitly call GR or not. I just had it explicitly called because I was trying different versions.

---

<div class="post-metadata">

### Author: ![SpinolaHours](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@SpinolaHours](https://discourse.julialang.org/u/SpinolaHours)
#### Post date: [October 5, 2022, 11:51am UTC](https://discourse.julialang.org/t/cannot-precompile-plots-jl-due-to-gr/88230/11 "2022-10-05T11:51:52Z")

</div>

I’ve also found I get a different error if I try to precompile GR\_jll directly:

julia\> using GR\_jll  
[Info: Precompiling GR\_jll [d2c73de3-f751-5644-a686-071e5b155ba9]  
ERROR: LoadError: InitError: could not load library “/home/jcooper/.julia/artifacts/a84cc58d5161b950f268bb562e105bbbf4d6004a/lib/libEGL.so”  
dlopen: cannot load any more object with static TLS  
Stacktrace:  
[1] dlopen(s::String, flags::UInt32; throw\_error::Bool)  
@ Base.Libc.Libdl ./libdl.jl:117  
[2] dlopen(s::String, flags::UInt32)  
@ Base.Libc.Libdl ./libdl.jl:116  
[3] macro expansion  
@ ~/.julia/packages/JLLWrappers/QpMQW/src/products/library\_generators.jl:54 [inlined]  
[4] **init** ()  
@ Libglvnd\_jll ~/.julia/packages/Libglvnd\_jll/pJrjy/src/wrappers/x86\_64-linux-gnu.jl:16  
[5] \_include\_from\_serialized(pkg::Base.PkgId, path::String, depmods::Vector{Any})  
@ Base ./loading.jl:831  
[6] \_tryrequire\_from\_serialized(modkey::Base.PkgId, path::String, sourcepath::String, depmods::Vector{Any})  
@ Base ./loading.jl:938  
[7] \_require\_search\_from\_serialized(pkg::Base.PkgId, sourcepath::String, build\_id::UInt64)  
@ Base ./loading.jl:1028  
[8] \_require(pkg::Base.PkgId)  
@ Base ./loading.jl:1315  
[9] \_require\_prelocked(uuidkey::Base.PkgId)  
@ Base ./loading.jl:1200  
[10] macro expansion  
@ ./loading.jl:1180 [inlined]  
[11] macro expansion  
@ ./lock.jl:223 [inlined]  
[12] require(into::Module, mod::Symbol)  
@ Base ./loading.jl:1144  
[13] include(mod::Module, \_path::String)  
@ Base ./Base.jl:419  
[14] top-level scope  
@ ~/.julia/packages/JLLWrappers/QpMQW/src/toplevel\_generators.jl:188  
[15] include  
@ ./Base.jl:419 [inlined]  
[16] 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:1554  
[17] top-level scope  
@ stdin:1  
during initialization of module Libglvnd\_jll  
in expression starting at /home/jcooper/.julia/packages/GR\_jll/48Bah/src/wrappers/x86\_64-linux-gnu-cxx11.jl:8  
in expression starting at /home/jcooper/.julia/packages/GR\_jll/48Bah/src/GR\_jll.jl:2  
in expression starting at stdin:1  
ERROR: Failed to precompile GR\_jll [d2c73de3-f751-5644-a686-071e5b155ba9] to /home/jcooper/.julia/compiled/v1.8/GR\_jll/jl\_DHHMuf.  
Stacktrace:  
[1] error(s::String)  
@ Base ./error.jl:35  
[2] compilecache(pkg::Base.PkgId, path::String, internal\_stderr::IO, internal\_stdout::IO, keep\_loaded\_modules::Bool)  
@ Base ./loading.jl:1705  
[3] compilecache  
@ ./loading.jl:1649 [inlined]  
[4] \_require(pkg::Base.PkgId)  
@ Base ./loading.jl:1337  
[5] \_require\_prelocked(uuidkey::Base.PkgId)  
@ Base ./loading.jl:1200  
[6] macro expansion  
@ ./loading.jl:1180 [inlined]  
[7] macro expansion  
@ ./lock.jl:223 [inlined]  
[8] require(into::Module, mod::Symbol)  
@ Base ./loading.jl:1144

---

<div class="post-metadata">

### Author: ![Lilith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lilith/32/27492_2.png) [@Lilith](https://discourse.julialang.org/u/Lilith)
#### Post date: [December 7, 2022, 9:07am UTC](https://discourse.julialang.org/t/cannot-precompile-plots-jl-due-to-gr/88230/12 "2022-12-07T09:07:46Z")

</div>

I got this same error message and `]add GR` fixed it for me.

---

<div class="post-metadata">

### Author: ![biona001](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/biona001/32/16497_2.png) [@biona001](https://discourse.julialang.org/u/biona001)
#### Post date: [March 20, 2023, 8:11pm UTC](https://discourse.julialang.org/t/cannot-precompile-plots-jl-due-to-gr/88230/13 "2023-03-20T20:11:36Z")

</div>

I’m getting the same issue, and adding/removing/building `GR` or `GR_jll` doesn’t work for me.

---

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [March 20, 2023, 8:34pm UTC](https://discourse.julialang.org/t/cannot-precompile-plots-jl-due-to-gr/88230/14 "2023-03-20T20:34:05Z")

</div>

There have been multiple errors mentioned in this thread, what does “same” specifically refer to? In general, opening a new thread with detailed error message you get plus all relevant information about your system, including the output of `versioninfo()`, would be more useful.

---

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [March 20, 2023, 8:36pm UTC](https://discourse.julialang.org/t/cannot-precompile-plots-jl-due-to-gr/88230/15 "2023-03-20T20:36:19Z")

</div>

Are you using a particularly old version of glibc by any chance? Your problem sounds like [17620 – DTV\_SURPLUS limits loading of Static TLS-requiring modules in multi-threaded programs](https://sourceware.org/bugzilla/show_bug.cgi?id=17620), which was fixed a few years ago. (Again, opening a different thread would have been more useful, there’s lots of noise in this thread now)

---

<div class="post-metadata">

### Author: ![biona001](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/biona001/32/16497_2.png) [@biona001](https://discourse.julialang.org/u/biona001)
#### Post date: [March 20, 2023, 8:44pm UTC](https://discourse.julialang.org/t/cannot-precompile-plots-jl-due-to-gr/88230/16 "2023-03-20T20:44:41Z")

</div>

Thanks for the response. Upgrading to Julia 1.8.4 resolved the issue for me (previously I was using 1.6.2 since that’s the default version on my cluster)

Below is my package versions on Julia 1.6.2

```julia
]st Plots GR GR_jll
      Status `/scratch/users/bbchu/.julia/environments/v1.6/Project.toml`
  [28b8d3ca] GR v0.71.8
  [91a5bcdd] Plots v1.38.8
  [d2c73de3] GR_jll v0.71.8+0

```

```julia
versioninfo()
Julia Version 1.6.2
Commit 1b93d53fc4 (2021-07-14 15:36 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: AMD EPYC 7742 64-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, znver2)
Environment:
  JULIA_DEPOT_PATH = /scratch/users/bbchu/.julia

```

---

<div class="post-metadata">

### Author: ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)
#### Post date: [August 3, 2023, 3:05pm UTC](https://discourse.julialang.org/t/cannot-precompile-plots-jl-due-to-gr/88230/17 "2023-08-03T15:05:25Z")

</div>

This error may be resolved as described in this post:

> [@Plots, InitError: UndefVarError: GR\_jll not defined](https://discourse.julialang.org/t/plots-initerror-undefvarerror-gr-jll-not-defined/102448):
>
> In some circumstances, a user may encounter the following error. Failed to precompile Plots [91a5bcdd-55d7-5caf-9e0b-520d859cae80] to "~/.julia/compiled/v1.9/Plots/jl\_crbDAx". ERROR: LoadError: InitError: UndefVarError: `GR_jll` not defined Stacktrace: [1] \_\_init\_\_() @ GR.GRPreferences ~/.julia/packages/GR/jehu0/src/preferences.jl:64

In short, run the following and then restart Julia.

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

```
