Issues Precompiling GLMakie

Hi all, not sure if this is the appropriate location for a general inquiry regarding a compile issue, although I wanted to ask if anyone could refer me to some resources on figuring out where I can get some understanding as to why GLMakie won’t precompile on my system. I believe this is definitely an issue with my linux distribution (I am using nixos, which has a ton of issues when trying to acces nonstandard binaries).

Even using the basic gr() package gave me errors when I tried to invoke the display() function. The only way I was able to see my code was by saving it to a PNG file and opening it up in my image viewer.

Below is the error I received:

Failed to precompile GLMakie [e9467ef8-e4e7-5192-8a1a-b1aee30e663a] to "/home/wytchblade/.julia/compiled/v1.12/GLMakie/jl_cFCv4S".
┌ Warning:     GLFW couldn't create an OpenGL window.
│     This likely means, you don't have an OpenGL capable Graphic Card,
│     or you don't have an OpenGL 3.3 capable video driver installed.
│     Have a look at the troubleshooting section in the GLMakie readme:
│     https://github.com/MakieOrg/Makie.jl/tree/master/GLMakie#troubleshooting-opengl.
└ @ GLMakie ~/.julia/packages/GLMakie/vdrwE/src/screen.jl:293
ERROR: LoadError: GLFWError (API_UNAVAILABLE): GLX: No GLXFBConfigs returned

This file is my plottingTests.jl which I used to test the various plotting backends:


using Pkg
# Ensure Plots is installed; GR comes built-in with Plots
Pkg.add("Plots")

using Plots

# 1. Set the backend to GR (Fast, high-quality static plots)
gr()

# 2. Define the data
n = 50
steps = randn(n)             # Generate 50 random steps
results = accumulate(+, steps) # The accumulator logic

# 3. Create the plot object
p = plot(
    1:n, 
    results, 
    title="Simple Accumulator (GR Backend)",
    xlabel="Step Number",
    ylabel="Accumulated Value",
    label="Running Total",
    linewidth=2,
    marker=:circle,
    markersize=4,
    grid=true,
    color=:crimson
)

# 4. Save the figure to the script's directory
# We use joinpath and @__DIR__ to ensure it saves next to this file
output_path = joinpath(@__DIR__, "accumulator_gr.png")
savefig(p, output_path)

println("Success! Plot saved to: ", output_path)

# Optional: Still display the plot if running in an IDE (like VS Code or Juno)
display(p)

The error you receive mentions GLMakie.jl which AFAIK should be unrelated to Plots.jl and GR. From your script, I can see that you add Plots.jl to your global default environment. This leads me to suspect that your global, default environment is rather cluttered with a lot of (probably outdated) packages which can lead to all sorts of problems like in this case a precompilation failure for a totally unrelated package. For checking my guess you could provide the output of Pkg.status().

Assuming my diagnosis is correct:

For a quick fix: Use a temporary enviroment in your script by adding Pkg.activate(; temp=true) before the call to Pkg.add("Plots"). This fix is fine for your small script here but using temporary enviroments for everything is not ideal (works but will lead to waiting times frequently and is tedious because you need to add code that sets up the env all the time).

For a more sustainable, long-term solution: Learn how to use enviroments in Julia. I recommend starting by reading the primer in Modern Julia Workflows:

So the first step is to delete all packages that you currently do not use from your global environment.

  • start julia with julia
  • enter the package manager with ]
  • the command st shows you which packages are installed
  • the command rm <PACKAGE_NAME> can be used to remove unused packages
  • the command up can be used to update the remaining packages

Then create a new project:

mkdir test
cd test
julia --project=.
using Pkg
Pkg.add("GLMakie") # or whatever you want to test

And see if precompilation succeeds now in a clean environment.

In general, try to avoid to install two graphics packages like Plots and GLMakie in the same project. This can result in conflicts.

Further reading: Working with Julia projects | Julia programming notes

If these steps do not help, please report back, and we can try to debug further.

To find out if OpenGL works on your machine, you can use the command line tools glxinfo or glxgears.

1 Like