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:
Thank you both @ufechner7 and @abraemer for your suggestions. I should mention that I am using nixos, and It seems like you have to enable compatibility with openGL manually. I was successfully able to compile the GLMakie package after doing this, however, when I attempt to execute code that uses the GLMakie API, the code errors out with the same error. I will test out isolating an environment and see if the code compiles there!
julia> # 4. Save to the current working directory
# Makie detects the format by the file extension (.png, .jpg, .pdf
)
save("my_scatterplot.png", fig);
┌ 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#troublesho
oting-opengl.
└ @ GLMakie ~/.julia/packages/GLMakie/vdrwE/src/screen.jl:293
ERROR: GLFWError (API_UNAVAILABLE): GLX: No GLXFBConfigs returned
I had a similar issue on NixOS lately. What worked for me is adding the following environment variable LD_LIBRARY_PATH = "/run/opengl-driver/lib/". You may need to enable nix-ld too to make some necessary libraries available.