GR can't connect on Windows

I installed Julia 1.6 on Windows a few days ago, and had been using the Plots package with no problems (GR backend only). Now, every time I plot, I get

GKS: can't connect to GKS socket application

GKS: Open failed in routine OPEN_WS
GKS: GKS not in proper state. GKS must be either in the state WSOP or WSAC in routine ACTIVATE_WS
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine FILLAREA
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine FILLAREA
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
...

Only things I can think of between then and now are: installing other packages (DifferentialEquations, SatelliteToolbox, SpecialMatrices, Convex, SCS, ECOS), updating my VS-Code Julia extension, and Windows OS updating.

Oddly, if I ran Julia with a pre-compiled image of the Plots library, then this issue would not occur.

Now, I’ve uninstalled Julia and deleted everything from the .julia folder to start with a clean slate. After running only three lines (] add Plots, using Plots, plot(1:3,1:3)) on the clean Julia install, the error still occurs. Also, the pre-compiled image no longer works. Any ideas what’s wrong or how to fix it?

1 Like

Have you tried the suggestions from:

1 Like

Yeah, I had seen those already, though none of those appear resolved, and none were under Windows.

The gksqt executable was where it should be:

julia> readdir(joinpath(ENV["GRDIR"],"bin"))
19-element Vector{String}:
 "cairoplugin.dll"
 "gksqt.exe"
 "glplugin.dll"
 "gr.js"
 "gsplugin.dll"
 "gtkplugin.dll"
 "libGKS.dll"
 "libGR.dll"
 "libGR3.dll"
 "libGRM.dll"
 "libqt5gr.dll"
 "pgfplugin.dll"
 "qt5plugin.dll"
 "qtplugin.dll"
 "svgplugin.dll"
 "videoplugin.dll"
 "wmfplugin.dll"
 "x11plugin.dll"
 "zmqplugin.dll"

Rerunning the build:

(@v1.6) pkg> build GR
    Building GR → `C:\...\.julia\scratchspaces\44cfe95a-1eb2-52ea-b672-e2afdf69b78f\31746d748c4ac35480d6f76517854e4066f4a8be\build.log`
Precompiling project...
  Progress [========================================>]  3/3
  ? Plots
1 dependency successfully precompiled in 14 seconds (253 already precompiled, 1 skipped during auto due to previous errors)
1 dependency failed but may be precompilable after restarting julia

The 1 dependency failed recurs even after restarting Julia. I tried it again as an administrator, and the new error is:

julia> using GR
Your GR installation is incomplete. Rerun build step for GR package.
    Building GR → `C:\...\.julia\scratchspaces\44cfe95a-1eb2-52ea-b672-e2afdf69b78f\31746d748c4ac35480d6f76517854e4066f4a8be\build.log`

julia> plot(1:3,1:3)
ERROR: could not load library "libGR.dll"
The specified module could not be found.
Stacktrace:
 [1] clearws
   @ ~\.julia\packages\GR\WDbN4\src\GR.jl:537 [inlined]
 [2] plot_data(flag::Bool)
   @ GR.jlgr ~\.julia\packages\GR\WDbN4\src\jlgr.jl:1136
 [3] plot_data
   @ ~\.julia\packages\GR\WDbN4\src\jlgr.jl:1113 [inlined]
 [4] plot(::UnitRange{Int64}, ::Vararg{UnitRange{Int64}, N} where N; kv::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ GR.jlgr ~\.julia\packages\GR\WDbN4\src\jlgr.jl:1669
 [5] plot(::UnitRange{Int64}, ::Vararg{UnitRange{Int64}, N} where N)
   @ GR.jlgr ~\.julia\packages\GR\WDbN4\src\jlgr.jl:1661
 [6] plot(::UnitRange{Int64}, ::Vararg{UnitRange{Int64}, N} where N; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ GR ~\.julia\packages\GR\WDbN4\src\GR.jl:3530
 [7] plot(::UnitRange{Int64}, ::Vararg{UnitRange{Int64}, N} where N)
   @ GR ~\.julia\packages\GR\WDbN4\src\GR.jl:3530
 [8] top-level scope
   @ REPL[2]:1

julia> readdir(joinpath(ENV["GRDIR"],"bin"))
ERROR: IOError: readdir("C:\\...\\.julia\\packages\\GR\\WDbN4\\src\\..\\deps\\gr\\bin"): no such file or directory (ENOENT)
Stacktrace:
 [1] uv_error
   @ .\libuv.jl:97 [inlined]
 [2] readdir(dir::String; join::Bool, sort::Bool)
   @ Base.Filesystem .\file.jl:830
 [3] readdir(dir::String)
   @ Base.Filesystem .\file.jl:825
 [4] top-level scope
   @ REPL[3]:1

For reference, GR\\WDbN4\\deps has no subfolders, and the GR folder has no dll anywhere inside it. Any thoughts on where to go from here?

1 Like

After a little more playing around, I’ve gotten everything to work again (hopefully it stays). For others referencing this, see the above step about running with admin privileges, because that may or may not matter. From there, referencing this page, I changed directory to Documents (or any folder in which you have write permissions), and ran

Pkg.update()
ENV["GRDIR"]=""
Pkg.build("GR")

This ran fine, and created GR/9Vi4m/deps/gr (which had all the dlls) and GR/9Vi4m/deps/downloads (which was empty). I still couldn’t get plots to work (maybe there’s some other environmental variables that need to be changed?), so from there, I copied the new gr folder to C:\...\.julia\packages\GR\WDbN4\deps (the existing GR install folder that was repeatedly troublesome) and restarted Julia. Now, both GR and Plots work fine.

1 Like

There is still a problem with the BinaryBuild version GR_jll for Windows. As a workaround, you can set ENV["JULIA_GR_PROVIDER"]="GR" and rebuild GR.

I have an idea what the problem is, but I have to make more tests. More information can be found here.

Sorry for that.
.

2 Likes