# Plots, InitError: UndefVarError: GR\_jll not defined

**URL:** https://discourse.julialang.org/t/plots-initerror-undefvarerror-gr-jll-not-defined/102448
**Category:** General Usage
**Tags:** plot
**Created:** [August 3, 2023, 1:43pm UTC](https://discourse.julialang.org/t/plots-initerror-undefvarerror-gr-jll-not-defined/102448 "2023-08-03T13:43:16Z")
**Posts on this page:** 1
**Showing post:** 2

<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, 1:43pm UTC](https://discourse.julialang.org/t/plots-initerror-undefvarerror-gr-jll-not-defined/102448/2 "2023-08-03T13:43:22Z")

</div>

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

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

```

This situation occurs due to some initial problem with loading GR\_jll on this line:

> <https://github.com/jheinen/GR.jl/blob/8ec015333c12f2c5728f4ec80a9d0ef54d26cdd4/src/preferences.jl#L6>

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):

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

```

If that succeeds, then try the following.

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

```

If `GR` function works, then try adding Plots.jl

```julia
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.

---

_[View the full topic](https://discourse.julialang.org/t/plots-initerror-undefvarerror-gr-jll-not-defined/102448)._
