client icon indicating copy to clipboard operation
client copied to clipboard

cannot open display: :0 on Wayland session

Open zimbipw opened this issue 5 years ago • 21 comments

Hello,

trying to start keybase-gui on Swaywm. Here's what appears in my journal: Sep 13 18:14:46 defiant systemd[939]: Starting Keybase GUI... Sep 13 18:14:46 defiant systemd[939]: Started Keybase GUI. Sep 13 18:14:48 defiant electron[16757]: cannot open display: :0 Sep 13 18:14:48 defiant systemd[939]: keybase.gui.service: Main process exited, code=exited, status=1/FAILURE Sep 13 18:14:48 defiant systemd[939]: keybase.gui.service: Failed with result 'exit-cod

my log id: c6eec7e406877d920c9d941c

THX Frank

zimbipw avatar Sep 13 '19 16:09 zimbipw

Hmm. What is your $DISPLAY?

heronhaye avatar Sep 13 '19 18:09 heronhaye

DISPLAY=:0

zimbipw avatar Sep 22 '19 18:09 zimbipw

I assume you're using the Arch community packages? @eli-schwartz any ideas?

heronhaye avatar Sep 24 '19 13:09 heronhaye

Swaywm is a Wayland compositor, it does not use X11. I don't use Wayland myself, so I'm not familiar with the best way to make sure an application is successfully started under XWayland.

I think that Electron applications require XWayland due to continuing lack of support in libchromiumcontent (and more generally, in the Chromium browser) for native Wayland.

...

Do you have xwayland disable specified in your Swaywm configuration?

eli-schwartz avatar Sep 24 '19 14:09 eli-schwartz

Yes I am using the package from the community repo.

x11wayland is not disabled in my config, xeyes for example is launching without any issues.

zimbipw avatar Sep 24 '19 19:09 zimbipw

Can you open a command line and run this command not in systemd:

electron /usr/share/keybase-app

eli-schwartz avatar Sep 24 '19 19:09 eli-schwartz

I found this https://github.com/swaywm/sway/issues/4050 and when I change GDK_BACKEND to x11 keybase-ui launches with GDK_BACKEND=wayland I'm getting this error for your suggested command: (electron:9920): Gtk-WARNING **: 10:40:34.478: cannot open display: :0

zimbipw avatar Sep 25 '19 08:09 zimbipw

Do not set GDK_BACKEND=wayland globally. This is known to break apps.

Instead, don't set anything. GTK will automatically choose the most appropriate backend.

emersion avatar Sep 26 '19 16:09 emersion

@zimbipw I don't know anything about wayland but you can set this environment variable only for keybase-gui.service using a systemd drop-in unit.

heronhaye avatar Sep 26 '19 16:09 heronhaye

that's pretty cool, thanks for the hint. However, I guess rather sooner than later you will need to look into supporting Wayland sessions

zimbipw avatar Sep 27 '19 07:09 zimbipw

I guess rather sooner than later you will need to look into supporting Wayland sessions

No, it's the other way around. Keybase doesn't need to do anything. However users need to make sure DISPLAY and WAYLAND_DISPLAY are correctly set when Keybase starts. This can be achieved by running systemctl --user import-environment on compositor startup.

emersion avatar Sep 27 '19 07:09 emersion

@zimbipw

For X11, the default xinitrc.d already sets up the necessary environment variables in the systemd user session. There is a downstream bug report for Arch Linux to do the same in our swaywm packaging as well, which will probably solve your issue: https://bugs.archlinux.org/task/63021

eli-schwartz avatar Sep 29 '19 04:09 eli-schwartz

I had this same issue and was able to fix it by creating a ~/.config/environment.d/.conf file:

$ cat ~/.config/environment.d/.conf
DISPLAY=:0
WAYLAND_DISPLAY=wayland-0

As detailed here.

I'm not sure if this command would have the same effect and could be placed in the sh script /usr/bin/keybase-gui?:

$ systemctl --user import-environment DISPLAY WAYLAND_DISPLAY

Vimru avatar Dec 26 '19 21:12 Vimru

The $DISPLAY variable is controlled by the file .config/keybase/keybase.autogen.env. It's also taken care of by /etc/X11/xinit/xinitrc.d/50-systemd-user.sh before that.

If your wayland session uses sway, then it is handled by /etc/sway/conf.d/10-systemd.conf

eli-schwartz avatar Dec 31 '19 16:12 eli-schwartz

Try

export DISPLAY=$WAYLAND_DISPLAY
export GDK_BACKEND=wayland

cab404 avatar Feb 13 '22 13:02 cab404

Exporting the Wayland display as the X11 one won't work.

emersion avatar Feb 13 '22 13:02 emersion

Exporting the Wayland display as the X11 one won't work.

that worked with gtk3-demo, so sometimes for some reason it does on some apps. didn't research it enough yet though.

cab404 avatar Feb 13 '22 14:02 cab404

It likely just makes the client fail to connect to X11, because DISPLAY is set to a bogus value.

emersion avatar Feb 13 '22 14:02 emersion

yeah, looks like it might be so

cab404 avatar Feb 13 '22 14:02 cab404

Install the xorg-xhost package, that should do the trick!

Prathyush-KKK avatar Aug 11 '23 19:08 Prathyush-KKK

I had this same issue and was able to fix it by creating a ~/.config/environment.d/.conf file:

$ cat ~/.config/environment.d/.conf
DISPLAY=:0
WAYLAND_DISPLAY=wayland-0

As detailed here.

I'm not sure if this command would have the same effect and could be placed in the sh script /usr/bin/keybase-gui?:

$ systemctl --user import-environment DISPLAY WAYLAND_DISPLAY

This issue recurs for me every now and then. Every time its a different solution that makes it work, like this one helped me the last time. Today, this too did not work, but launching it from the root terminal did the job (not with sudo). All the env variables I know are the same in both root and user. Can someone tell me what am I missing here?

abinlatheef avatar Dec 27 '23 05:12 abinlatheef