Generation of documentation fails: "qt.qpa.xcb: could not connect to display"

I am able to generate the documentation locally, but when I try to do so on Github I get the following errors during execution of make.jl:

[ Info: SetupBuildDirectory: setting up build directory.
[ Info: Doctest: running doctests.
[ Info: ExpandTemplates: expanding markdown templates.
qt.qpa.xcb: could not connect to display 
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: linuxfb, minimal, offscreen, vnc, xcb.

Aborted (core dumped)
connect: Connection refused
GKS: can't connect to GKS socket application

The package is PSSFSS.jl and the documentation build log is here
I thought it was allowed to include plots in the online generated documentation. Is that correct? If that’s not it, then I could sure use some help debugging this. Thanks in advance.

2 Likes

I see you’re using Plots.jl, and “GKS” sounds like the GR backend. In that case, set the magic environmental variable

ENV["GKSwstype"] = "100"

which tells it to operate in “headless” mode where it doesn’t expect an active display connected. (AFAIK this is undocumented but it’s super useful!).

17 Likes

Thanks! That did the trick (for that error, at least).

1 Like

For anyone wondering where this information originated from, see Workstation Types — GR Framework 0.66.0 documentation.

1 Like

@PeterSimon and @ericphanson
I have the same problem as @PeterSimon initially described.
So, which file should I add the line ENV["GKSwstype"] = "100" ? Should it be in docs/make.jl?
Thanks a lot in advance!

For generating documentation it goes in the env: section of your CI.yml file.
See, for example these lines

1 Like

@PeterSimon, thanks. I followed exactly what you said, and checked your CI.yml in PSSFSS.jl. Yet, I got the same error as before:

Run julia --project=docs/ docs/make.jl
  julia --project=docs/ docs/make.jl
  shell: /usr/bin/bash -e {0}
  env:
    GITHUB_TOKEN: ***
    DOCUMENTER_KEY: 
[ Info: SetupBuildDirectory: setting up build directory.
[ Info: Doctest: running doctests.
[ Info: ExpandTemplates: expanding markdown templates.
qt.qpa.xcb: could not connect to display 
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: linuxfb, minimal, offscreen, vnc, xcb.

Aborted (core dumped)
connect: Connection refused
GKS: can't connect to GKS socket application
...

I put it there, yeah.

1 Like

You don’t explicitly show that you included the GKSwstype environment variable. Could you provide a link to your Github CI.yml file so we can look it over?

@PeterSimon ; thanks a lot. Here is the link to our CI.yml: MultiscaleGraphSignalTransforms.jl/CI.yml at master · UCD4IDS/MultiscaleGraphSignalTransforms.jl (github.com)

Your CI.yml file looks OK to me (though I am far from an expert on this).
When I look at your log files, I see that the GKSwtype environment variable is not set during your documentation run. (You apparently copied a portion of the log file in your last post.) I am by no means proficient at this stuff, but I do notice that your listing shows

env:
GITHUB_TOKEN: ***
DOCUMENTER_KEY:

There are no asterisks after DOCUMENTER_KEY as there are after GITHUB_TOKEN. In the log file for my project, there are asterisks after both of these. I am totally speculating here, but perhaps you didn’t set up DOCUMENTER_KEY and maybe this caused the setting of the environment variables to be terminated before reaching GKSwstype setting. If this isn’t it, then perhaps someone more expert on these matters can help you.

Thanks a lot! After all, I forgot that I have another yml file called Documenter.yml under .github/workflow/, which deals with everything related to the docs. I added that magic line under the env item, it worked!

When I use this line in my julia, it starts to not showing the graph. Where does the graph go?