# GR build problems: "installation is incomplete"

**URL:** <https://discourse.julialang.org/t/gr-build-problems-installation-is-incomplete/58764>\
**Category:** General Usage\
**Tags:** plotting\
**Created:** [April 7, 2021, 3:13pm UTC](https://discourse.julialang.org/t/gr-build-problems-installation-is-incomplete/58764 "2021-04-07T15:13:07Z")\
**Posts on this page:** 1\
**Showing post:** 22

<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:** [April 7, 2021, 10:17pm UTC](https://discourse.julialang.org/t/gr-build-problems-installation-is-incomplete/58764/22 "2021-04-07T22:17:40Z")

</div>

# Background: GR Binaries

There are two ways to provide binaries for GR which hinge on the environmental variable `JULIA_GR_PROVIDER`. You can evaluate that environmental variable by checking the value of `ENV["JULIA_GR_PROVIDER"]` within Julia or use operating system and shell specific means outside of Julia. The two methods are “BinaryBuilder” and “GR” with “BinaryBuilder” being preferred.

[https://github.com/jheinen/GR.jl/blob/master/deps/build.jl#L70-L92](https://github.com/jheinen/GR.jl/blob/master/deps/build.jl#L70-L92)

The BinaryBuilder binary provider method uses GR\_jll which are binaries built via cross-compilation by the Julia’s [BinaryBuilder.org](http://BinaryBuilder.org) ecosystem: [GitHub - JuliaBinaryWrappers/GR\_jll.jl](https://github.com/JuliaBinaryWrappers/GR_jll.jl)

The GR method binary provider downloads tarballs from [Index of /downloads/](https://gr-framework.org/downloads/)

Problems can occur if the binaries and the Julia package get out of sync. You may be trying to update GR\_jll, but at the end of the day it will not matter because you are actually use the tarball. Going the other way, you might be trying to redownload the tarball, but perhaps the Julia package is using GR\_jll.

# Source of the Error

> [@compleat](#):
>
> The initial error message many of them are getting is:
> 
> ```julia-auto
> Your GR installation is incomplete. Rerun build step for GR package
> 
> ```

The error comes from GR.jl’s ` __init__ ` function (nb: GR.jl has an ` __init__ ` and an `init` function) when it cannot locate the directory of the GR install via the Julia variable `grdir` in that function. That Julia variable can modified via the environmental variable `GRDIR`.

> <https://github.com/jheinen/GR.jl/blob/813fba7c2731751701628f3c366990182c7718b2/src/GR.jl#L259-L286>

> <https://github.com/jheinen/GR.jl/blob/1e6d3d526ed8ca5757f371c618fd41f83a1012c1/src/GR.jl#L277-L280>

# Troubleshooting

I recommend working backwards in situations like this.

1. What is the value of the local variable `grdir` in `GR. __init__ ` ?
2. What is the value of `GR.gr_provider`?

```julia
julia> GR.gr_provider
"BinaryBuilder"

```

## BinaryBuilder

GR\_jll.jl is a binary package created by Julia’s binary builder ecosystem. It is distinct from GR.jl. If you are having trouble with GR\_jll.jl please make sure to indicate that when seeking help.

If the value of `GR.gr_provider` is “BinaryBuilder”, the continue troubleshooting down this path:

1. What is the value of `joinpath(dirname(GR_jll.libGR_path), "..")`? You may need to manually load GR\_jll via `using GR_jll` to evaluate this and may need to explicitly add it to your environment.
2. What is located at the value of the expression above? Is it valid?
3. What is the version of `GR_jll` in your manifest?

If you determine that GR\_jll is the problem, please indicate that when seeking help.

## GR or other values of `GR.gr_provider`

If the value of `GR.gr_provider` is not “BinaryBuilder”, then we may need to investigate how that came to be.

> <https://github.com/jheinen/GR.jl/blob/813fba7c2731751701628f3c366990182c7718b2/src/GR.jl#L13-L32>

`GR.gr_provider` is a compile time constant which is contingent on deps.jl. Locate “deps.jl” by obtaining the value of the compile time constant `GR.depsfile`. You should then examine the content of deps.jl. deps.jl is not located in the GR.jl source tree, because it is generated by build.jl:

[https://github.com/jheinen/GR.jl/blob/master/deps/build.jl#L78-L86](https://github.com/jheinen/GR.jl/blob/master/deps/build.jl#L78-L86)

build.jl is invoked when you do “] build GR” in the package interface or do `using Pkg; Pkg.build("GR")`.

Looking through build.jl there are two environmental variables that influence the selection of a binary provider:

1. [`GRDIR`](https://github.com/jheinen/GR.jl/blob/master/deps/build.jl#L9)
2. [`JULIA_GR_PROVIDER`](https://github.com/jheinen/GR.jl/blob/master/deps/build.jl#L71)

Further troubleshooting would thus involve clearing or manipulating these environmental variables and then invoking `] build GR`. That should in turn influence the existence or contents of “deps.jl” and `GR.gr_provider`.

### Troubleshooting Steps for non-BinaryBuilder binary provider install

The first step to fix this is just to do

> [@Tiny Plots in jupyter-notebook](https://discourse.julialang.org/t/tiny-plots-in-jupyter-notebook/53344/7):
>
> Please update using ENV["GRDIR"]=""; ] build GR.

That should look like this, first checking what the current value of the GRDIR environmental variable:

```julia-auto
julia> ENV["GRDIR"]
"C:\\Users\\kittisopikulm\\.julia\\artifacts\\7d224ea2f9a0db864ae942e168f53343cb07aaa6\\bin\\.."

julia> ENV["GRDIR"] = ""
""

(@v1.6) pkg> build GR
    Building GR → `C:\Users\kittisopikulm\.julia\dev\GR\deps\build.log`
...

```

#### What does `ENV["GRDIR"]=""; ] build GR` do?

The first thing it does is looks for a “gr” folder in your home directory, “/opt”, “/usr/local”, or “/usr”. If you’re on Windows, you probably only have a home directory.

[https://github.com/jheinen/GR.jl/blob/master/deps/build.jl#L16-L22](https://github.com/jheinen/GR.jl/blob/master/deps/build.jl#L16-L22)

```julia-auto
julia> homedir()
"C:\\Users\\kittisopikulm"

```

If that fails `get_grdir` returns `Nothing`. (It returns the type `Nothing` as opposed to an instance of `nothing`.)

Later, this in turn results in `provider` being set to `"BinaryBuilder"`:

[https://github.com/jheinen/GR.jl/blob/master/deps/build.jl#L72-L73](https://github.com/jheinen/GR.jl/blob/master/deps/build.jl#L72-L73)

It’s important to check this, since a couple of weeks ago, that was not the case:

[https://github.com/jheinen/GR.jl/commit/1e6d3d526ed8ca5757f371c618fd41f83a1012c1#diff-708e1c220f34be9ffbf04c0619b1f1a56388096c1df2b95603950d7adc80feaa](https://github.com/jheinen/GR.jl/commit/1e6d3d526ed8ca5757f371c618fd41f83a1012c1#diff-708e1c220f34be9ffbf04c0619b1f1a56388096c1df2b95603950d7adc80feaa)

> <https://github.com/jheinen/GR.jl/blob/1e6d3d526ed8ca5757f371c618fd41f83a1012c1/deps/build.jl#L70-L76>

More directly you can also set the environmental variable `ENV["JULIA_GR_PROVIDER"]` explicitly to either “BinaryBuilder” or “GR” before rebuilding via “] build GR”.

# Summary

1. Collect information based on tracing the source of the error:
2. What is the version of the GR and GR\_jll packages?
3. What is the value of `GR.gr_provider`?
4. What are the values of the environmental variables JULIA\_GR\_PROVIDER and GRDIR?
5. What happens when you clearr the environmental variable GRDIR?

```julia-auto
julia> ENV["GRDIR"]
"C:\\Users\\kittisopikulm\\.julia\\artifacts\\7d224ea2f9a0db864ae942e168f53343cb07aaa6\\bin\\.."

julia> ENV["GRDIR"] = ""
""

(@v1.6) pkg> build GR
    Building GR → `C:\Users\kittisopikulm\.julia\dev\GR\deps\build.log`
...

```

Does any of the above variables and constants change?  
6. What happens when you do `ENV["JULIA_GR_PROVIDER"] = "BinaryBuilder"` and then do `using Pkg; pkg"build GR"` ?  
7. What happens when you do `ENV["JULIA_GR_PROVIDER"] = "GR"` and then do `using Pkg; pkg"build GR"` ?

I hope this expanded guide to troubleshooting GR helps you and your students. More generally when you get stuck like this I suggest tracing the source of the error and then walking through the process to debug. When you discover constants or environmental variables try evaluating to see what they are and then later see if modifying them changes the situation.

---

_[View the full topic](https://discourse.julialang.org/t/gr-build-problems-installation-is-incomplete/58764)._
