keybase / client

Keybase Go Library, Client, Service, OS X, iOS, Android, Electron
BSD 3-Clause "New" or "Revised" License
8.89k stars 1.23k forks source link

cannot open display: :0 on Wayland session #19614

Open zimbipw opened 5 years ago

zimbipw commented 5 years ago

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

heronhaye commented 5 years ago

Hmm. What is your $DISPLAY?

zimbipw commented 5 years ago

DISPLAY=:0

heronhaye commented 5 years ago

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

eli-schwartz commented 5 years ago

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?

zimbipw commented 5 years ago

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.

eli-schwartz commented 5 years ago

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

electron /usr/share/keybase-app

zimbipw commented 5 years ago

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

emersion commented 5 years ago

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.

heronhaye commented 5 years ago

@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.

zimbipw commented 5 years ago

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

emersion commented 5 years ago

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.

eli-schwartz commented 5 years ago

@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

Vimru commented 4 years ago

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
eli-schwartz commented 4 years ago

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

cab404 commented 2 years ago

Try

export DISPLAY=$WAYLAND_DISPLAY
export GDK_BACKEND=wayland
emersion commented 2 years ago

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

cab404 commented 2 years ago

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.

emersion commented 2 years ago

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

cab404 commented 2 years ago

yeah, looks like it might be so

Prathyush-KKK commented 1 year ago

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

abinlatheef commented 9 months ago

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?