Skip to content

Can't open display: :0 after enabling systemd #8899

Closed

Description

Version

10.0.22622.601

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.15.62.1

Distro Version

Ubuntu 22.04 (jammy)

Other Software

Google Chrome
Firefox Browser
X11-Apps

Repro Steps

enable systemd on the distro, try to run an x11 app (example: the x11-apps, google chrome, firefox, etc)

Expected Behavior

the app opens with no problem

Actual Behavior

the terminal outputs "Error: Can't open display: :0"

Diagnostic Logs

No response

Activity

  1. cerebrate commented on Sep 27, 2022

    @cerebrate

    See responses to #8888.

  2. cerebrate commented on Sep 27, 2022

    @cerebrate

    the gnome apps (the only ones that worked)

    ...this would have been good to know right at the start, because if any X apps worked at all, such as the Gnome ones, then we've been trying to solve the wrong problem all along (if the X socket were missing, Gnome apps should also fail with "can't open display"), and the #8888 solutions don't apply.

    So the first step in figuring this out would be to undo all the things done in attempting to solve that problem, so we can get a good look at this one.

    (Starting with the outputs of ls -la /tmp/.X11-unix, env, and ls -la /mnt/wslg/runtime-dir, I think.)

  3. cerebrate commented on Sep 27, 2022

    @cerebrate

    Okay, well that tells me a few things. First up, it looks like your Gnome apps are using Wayland, 'cause the X11 config is definitely broken (/tmp/.X11-unix is empty). DISPLAY environment variable is there, though, so that's okay.

    Let's check if the WSLg X socket is being properly created. If you ls -la /mnt/wslg/.X11-unix, it should come back to you with (your date and username will vary)

    total 0
    srwxrwxrwx 1 avatar avatar 0 Sep 26 13:32 X0=
    

    Does it?

  4. cerebrate commented on Sep 27, 2022

    @cerebrate

    Huh. Well, that's very strange and unfortunately nothing I've seen before. WSLg should be creating the X socket in that location automatically.

    There's not a lot I can do to diagnose this one further, but I suggest you open an issue over at the WSLg repository:

    https://github.com/microsoft/wslg

    ...because it's probably their issue. I see there are a couple of similar ones (like microsoft/wslg#838 and microsoft/wslg#844 ) there already, so hopefully it's already on their radar.

  5. mangkoran commented on Sep 28, 2022

    @mangkoran

    Apologize for jumping in (and could not help :)).

    Interestingly enough, while I also encounter blank DISPLAY envvar, I am still able to use Emacs GUI 🤔

    image

    However, chromium and firefox cannot be opened, same as this thread.

    Alistair Young (@cerebrate) could you confirm this behaviour too?

  6. cerebrate commented on Sep 28, 2022

    @cerebrate

    mangkoran (@mangkoran) You're using emacs-daemon via a user systemd service though, right? In which case it should work fine as long as systemctl --user show-environment has DISPLAY and can pass it on to the emacs service.

  7. mangkoran commented on Sep 28, 2022

    @mangkoran

    ..except it's not 🧐

    ❯ systemctl --user show-environment
    HOME=/home/mangkoran
    LANG=en_US.UTF-8
    LOGNAME=mangkoran
    MAIL=/var/spool/mail/mangkoran
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
    SHELL=/usr/bin/fish
    SYSTEMD_EXEC_PID=89
    USER=mangkoran
    XDG_RUNTIME_DIR=/run/user/1000
    DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
    
  8. cerebrate commented on Sep 28, 2022

    @cerebrate

    What version of Emacs are you running? It's at least possible - if it's very recent - that it's running as a pure Wayland app.

  9. mangkoran commented on Sep 28, 2022

    @mangkoran

    28.1 (+pgtk +nativecomp) which is indeed native Wayland. I guess I am mistook this issue since the beginning 😅

  10. 50 remaining items

  11. haritha99ch commented on Nov 16, 2022

    @haritha99ch

    On both Ubuntu-Preview and Kali-Linux, x11-apps worked fine until a desktop environment was installed.
    WSL version: 1.0.0.0

  12. linghengqian commented on Nov 16, 2022

    @linghengqian

    On both Ubuntu-Preview and Kali-Linux, x11-apps worked fine until a desktop environment was installed.
    WSL version: 1.0.0.0

    • Installing the standard gnome desktop environment on a WSL distribution with systemd built in is a separate issue, which is very different from the process of installing a GUI application via snapcraft.io after opening systemd.

    • You should bring the reproduction steps to open the new issue.

  13. linghengqian commented on Nov 18, 2022

    @linghengqian

    However, my experience wirh Wslg, is its premature stage. Nautilus and Gdebi behave strange when click back and fort in files choosing dialog. Sometimes the dialog occupies multiple screens, and becomes uncontrollable.

  14. PhyX-Meow commented on Nov 25, 2022

    @PhyX-Meow

    The issue is back with wsl 1.0.1 on my machine. :(

  15. linghengqian commented on Nov 25, 2022

    @linghengqian

    The issue is back with wsl 1.0.1 on my machine. :(

    • Can you open a new issue showing as complete steps to reproduce as possible? The steps to reproduce the current issue seem to include many versions, but my Ubuntu WSL 22.04 works fine with WSL 1.0.1.
  16. lisp-the-great commented on Dec 27, 2022

    @lisp-the-great

    Hello all, I was having this issue too. I was able to fix it after making a new file called /usr/lib/binfmt.d/WSLInterop.conf and writing the contents: :WSLInterop:M::MZ::/init:PF.

    This may or may not solve your problem, if the file already exists it won't fix your issue. Worth a try.

    THANKS! I'm using windows10 and updated wsl to the store version recently. when enabling the systemd (edit boot section of /etc/wsl.conf), the GUI apps disappears. My /tmp/.X11-unix and env DISPLAY and any more things are all correct.

    This works for me.

    I've saw the original /usr/lib/binfmt.d/WSLInterop.conf file with content :WSLInterop:M::MZ::/init:F, and when change it with .../init:PF and restart the wsl, then it bring my Emacs back!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions