Electron: Missing X server or $DISPLAY
Asked Answered
A

2

7

I've been running an Electron App on a Pi4, Ubuntu 22.04 Server, and Gnome desktop without issue. Since it runs as a kiosk anyway as a single app, I've been attempting to eliminate Gnome and just launching from the CLI (with X installed). However, I'm getting:

ERROR:ozone_platform_x11.cc(247) Missing X server or $DISPLAY
The platform failed to initialize. Exiting.

I've read about setting "DISPLAY=$HOST_IP:10.0", however I'm not clear where that would be set, or if that's applicable to this situation. I'm pretty new to this part, so any help would be appreciated!

Arquebus answered 15/9, 2022 at 4:22 Comment(0)
A
2

The display is set as an environment variable on the xclient side so it knows where to send the output at the xserver. For example, if I'm running the xserver on a Windows box at 192.168.0.5 then on the client do:

$ export DISPLAY=192.168.0.5:0.0

This will tell the xclient to send output to that url on display zero. You can have more than one display but for this example we will keep it simple.

If your xclient is, say, Ubunto via WSL2 on Windows you can simply put this line in the Ubunto ~/.bash file and it will automagically figure out the correct display value:

# enable the display for XWindows

export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0

To verify your display is set do:

$ echo $DISPLAY

172.26.112.1:0.0 <-- just an example url, probably not yours

Away answered 30/9, 2022 at 20:38 Comment(2)
I tried the above solution but it still doesn't work also... I was using Docker environment with DebianEade
Please add to your question above the actual CLI command you are using and show the output error. This could be unrelated to the DISPLAY variable but I need to see the CLI to help determine the cause. If we need to take this offline please let me know.Away
D
0

At Raspberry PI 4, I did:

$ export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0

and it ended up as:

$ echo $DISPLAY
192.168.0.1:0.0

But still same problem - Missing X Server

My final solution:

$ export DISPLAY=:0

Then worked fine!

Delores answered 26/9 at 19:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.