Skip to content

WSLg - Works from Windows Menu, but impossible to launch from terminal #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
goupil35000 opened this issue Apr 23, 2021 · 7 comments
Closed
Labels
bug Something isn't working

Comments

@goupil35000
Copy link

Environment

Windows build number: Microsoft Windows [Version 10.0.21364.1]
Your Distribution version: Ubuntu Release: 20.04
Your WSLg version: 1.0.17.1

After update wsl and install gedit in Ubuntu:

  • I can launch editor from Windows Menu and it works great.
  • In Ubuntu, if I type gedit it doesn't work.

Expected behavior

I want to be able to launch all applications from Ubuntu.

@goupil35000 goupil35000 added the bug Something isn't working label Apr 23, 2021
@goupil35000
Copy link
Author

It works after changing DISPLAY value.

By default, DISPLAY=192.168.1.60:0
I change it to with this command:
export DISPLAY=:0.0

And I'm able to launch gedit from ubuntu terminal.

@crramirez
Copy link
Contributor

I think that something is changing you the DISPLAY environment variable, maybe a previous configuration for X Server?

Look into your .bashrc or /etc/profile.d looking for a script that is setting the variable. Ubuntu used to have a file called wsl-integration in /etc/profile.d

By default, DISPLAY should be :0. If it is anything else, something in your distro is changing it.

@gustalima
Copy link

You also need to provide WAYLAND_DISPLAY.

export WAYLAND_DISPLAY=wayland-0

Another way of checking this out is

1 - Open terminator from Start Menu
2 - echo $DISPLAY
3 - echo $WAYLAND_DISPLAY
4 - echo $PULSE_AUDIO
5 - add this variables and their assignments to your session

Cheers

@hakiri
Copy link

hakiri commented Apr 23, 2021

The same issue come back after installing the workaround of systemd and docker native.
$ xclock
Error: Can't open display: :0

@hakiri
Copy link

hakiri commented Apr 23, 2021

The problem solved again after setting up DISPLAY in .bashrc using the cmd
I installed GWSL from microsoft store to make it working

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

@eternalphane
Copy link

eternalphane commented Apr 24, 2021

@hakiri to actually make it work (when using systemd/docker) without installing other xserver, see this comment.

@spronovo
Copy link
Collaborator

Folks in the thread are correct, WSL's INIT pre-configure the following environment variable before your profile is applied:

DISPLAY=:0
WAYLAND_DISPLAY=wayland-0
XDG_RUNTIME_DIR=/mnt/wslg/runtime-dir
PULSE_SERVER=/mnt/wslg/PulseServer

If you change your profile, or run software that changes those value, you'll lose connection to one of those server and things will break. This is by design and allow you to run other servers if you would prefer (you can even disable WSLg GUI entirely if you wish).

Seems like everyone in this thread got their connection working, resolving this issue.

If you see folks struggling with their connection, please have them take a look at this wiki:

https://github.com/microsoft/wslg/wiki/Diagnosing-%22cannot-open-display%22-type-issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants