Comment 13 for bug 1914601

Revision history for this message
Mark Mitrushkin (mark-mitrushkin) wrote :

Hi,

How do you test?

- Which version of WSL you are using?
- What is the output of `echo $DISPLAY` if you open a terminal from the link created by wslu?
- What is the content of `/etc/resolv.conf`?

I found where the issue is. On "wslu v3.2.1-1; wslusc v40", in `/usr/share/wslu/wslusc-helper.sh` if I comment the following code, the shortcuts start working:

# if ( eval "$ipconfig_exec" | grep -n -m 1 "Default Gateway.*: [0-9a-z]" | cut -d : -f 1 ) >/dev/null; then
# set +H
# wsl2_d_tmp="$(eval "$ipconfig_exec" | grep -n -m 1 "Default Gateway.*: [0-9a-z]" | cut -d : -f 1)"
# wsl2_d_tmp="$(eval "$ipconfig_exec" | sed $(( wsl2_d_tmp - 4 ))','$(( wsl2_d_tmp + 0 ))'!d' | grep IPv4 | cut -d : -f 2 | sed -e "s|\s||g" -e "s|\r||g")"
# set -H
# export DISPLAY=${wsl2_d_tmp}:0.0
# else
    wsl2_d_tmp="$(grep nameserver /etc/resolv.conf | awk '{print $2}')"
    export DISPLAY=${wsl2_d_tmp}:0
# fi

This means the script is not setting DISPLAY variable properly and no matter which X11 server you are using, it won't connect since on WSL2 it is not in the local network. Here is what the script does without commenting:

$ echo $DISPLAY
172.24.224.1:0 # this is what the IP should be
$ unset DISPLAY
/usr/share/wslu$ . ./wslusc-helper.sh
$ echo $DISPLAY
192.168.0.16:0.0 # this is what the scripts sets, this would work on WSL1 where host and WSL are on the same network, but on WSL2 it won't work