GUI apps do not start from the link created

Bug #1914601 reported by Mark Mitrushkin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
wslu (Ubuntu)
Fix Committed
Undecided
Unassigned

Bug Description

Description: Ubuntu 20.04.2 LTS
Release: 20.04

wslu:
  Installed: 2.3.6-0ubuntu2~20.04.0
  Candidate: 2.3.6-0ubuntu2~20.04.0
  Version table:
 *** 2.3.6-0ubuntu2~20.04.0 500
        500 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     2.3.6-0ubuntu1 500
        500 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages

C:\Users\username\Desktop>wsl -l -v
  NAME STATE VERSION
* Ubuntu-20.04 Running 2

$ wslusc --version
wslu v2.3.6; wslusc v37

$ wslusc terminator
[info] Create shortcut terminator.lnk successful

C:\Users\username\Desktop>terminator.lnk
Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused
You need to run terminator in an X environment. Make sure $DISPLAY is properly set

$ wslusc --gui terminator
[info] Create shortcut terminator.lnk successful

C:\Users\username\Desktop>terminator.lnk
<nothing happens>

Looks like DISPLAY propery is not set correctly by the underlying script:

$ pwd
/usr/share/wslu
$ export DISPLAY=SHOULD_BE_SET
$ . wsl-integration.sh
$ echo $DISPLAY
SHOULD_BE_SET

summary: - GUI apps do not work
+ GUI apps do not work from the link created
summary: - GUI apps do not work from the link created
+ GUI apps do not start from the link created
Revision history for this message
Patrick Wu (callmepk) wrote :

Hi,

For GUI apps, -g should be passed when creating shortcuts.

Can you run `wslusc -g terminator` and check it again? Thanks

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

Hi,

As you can see from bug description, I also tried --gui flag which also did not produce a working link.

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

Also, if I open the desktop shortcut properties I see that target is truncated:

C:\Windows\System32\wscript.exe C:\\Users\\username\wslu\runHidden.vbs "C:\\Users\\username\\AppData\\Local\\Microsoft\\WindowsApps\\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\\ubuntu2004.exe" run "cd ~; . /usr/share/wslu/wsl-integration.s

Could be that the target is too long when `--gui` flag is used?

Without `--gui` flag, the target is much shorter:

C:\Users\username\AppData\Local\Microsoft\WindowsApps\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\ubuntu2004.exe run "cd ~; terminator"

Revision history for this message
Patrick Wu (callmepk) wrote :

Hi,

> Could be that the target is too long when `--gui` flag is used?

This is the normal behavior of properties window that they will display to be truncated, but actually not. Editing it will result in actual truncation.

---

Also, since 20.04 package is outdated, and the package is currently still waiting for the update here: #1911432, can you try the PPA version before it gets merged, and see if it works? https://launchpad.net/~wslutilities/+archive/ubuntu/wslu

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

Hi,

I've tested the version from PPA:

$ wslusc --version
wslu v3.2.1-1; wslusc v40
$ wslusc --gui terminator
[warn] wsl-term.ico not found in Windows directory. Copying right now...
[info] wsl-term.ico copied. Located at "/mnt/c/Users/username/wslu".
[warn] wsl-gui.ico not found in Windows directory. Copying right now...
[info] wsl-gui.ico copied. Located at "/mnt/c/Users/username/wslu".
[info] Create shortcut terminator.lnk successful

And the shortcut doesn't work and I think I know why. DISPLAY option is not set properly by the script:

$ echo $DISPLAY
172.18.96.1:0 # this should be the correct one
$ unset DISPLAY
$ . wslusc-helper.sh
$ echo $DISPLAY
192.168.0.16:0.0 # this is what is set by the script

The correct way would be setting DISPLAY from /etc/reslv.conf:

$ cat /etc/resolv.conf
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 172.18.96.1

Revision history for this message
Patrick Wu (callmepk) wrote :

Hi,

what X server are you using and are you using WSL1 or WSL2?
Also, can you wait a minute after opening the shortcut to see if it opens later? Sometimes I will load after several minutes in some cases.

Revision history for this message
Patrick Wu (callmepk) wrote :

I have tested with VcXsrv on Windows 10 2004 and X410 on the Dev channel and both have no issue.

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

Hi,

I am using Xming 7.7.0.60 on Windows 10 Pro 20H2 version 19042.746 build with WSL2.

Even after a while the GUI won't open. If I run `terminator` command from wsl terminal it opens fine on Xming, so I don't think it's X server issue. And before `apt update` yesterday, those desktop shortcuts worked just fine.

My assumption, is that `wslu v3.2.1-1; wslusc v40` assumes you have WSL1 and sets DISPLAY to a local IP which would not work in WSL2 since it's not local network anymore.

And from what I've seen `wslu v2.3.6; wslusc v37` version doesn't set DISPLAY propery at all.

Revision history for this message
Patrick Wu (callmepk) wrote :

Interesting. I will need to take a further look

Changed in wslu (Ubuntu):
status: New → Incomplete
status: Incomplete → Confirmed
Revision history for this message
Patrick Wu (callmepk) wrote :

Can you show your system information using `wslsys`?

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

$ wslsys
WSL Version: 2
Locale: en_GB
Release Install Date: Tue Jul 21 18:00:49 CEST 2020
Branch: vb_release
Build: 19042
Full Build: 19041.1.amd64fre.vb_release.191206-1406
Display Scaling: 1
Windows Theme: light
Windows Uptime: 1d 0h 25m
WSL Uptime: 0d 8h 25m
WSL Release: Ubuntu 20.04.2 LTS
WSL Kernel: Linux 5.4.72-microsoft-standard-WSL2
Packages Count: 1449

Revision history for this message
Patrick Wu (callmepk) wrote :

Hi,

After several local testing, I am still unable to find the issue... Have you tried to use other X Servers?

Changed in wslu (Ubuntu):
status: Confirmed → Incomplete
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

Patrick Wu (callmepk)
Changed in wslu (Ubuntu):
status: Incomplete → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.