I just opened an issue asking how to use GR without graphical server (https://github.com/jheinen/GR.jl/issues/442) and would like to give a bit of context here. I have a Debian server on which I want to produce automatically some png/svg/plotly-html plots every day using Julia and serve the files with Nginx. However, I encounter a segfault error that seems to be due to the lack of graphical server. Did anybody met the same problem? How to fix it?
Hum. This definitely should be documented.
I closed the issue because the
ENV["GKSwstype"] = "100" solved it, but now, I have a different problem:
When doing in the REPL
using GR ENV["GKSwstype"] = "100" function toto() p = histogram(randn(100)) savefig("fig.png") end toto()
I get the png output as expected but when I put the previous code in a module
Toto inside a
Toto.jl file and call
using Toto; Toto.toto() from the REPL, I get the segfault again. So now the question becomes: how to make GR aware of environment variables set in a module?
The answer I found uses the system environment variables e.g.
export GKSwstype=100 before starting Julia. I would have preferred not to use them and go for a pure Julia fix, but here we are…
For what it is worth, the CairoMakie backend for Makie is generally much easier to configure on systems without a GUI. Or UnicodePlots of course
Please just swap the first two lines:
ENV["GKSwstype"] = "100" using GR
BTW: It’s documented here.