microsoft / wslg

Enabling the Windows Subsystem for Linux to include support for Wayland and X server related scenarios
MIT License
10.16k stars 304 forks source link

WSLg environment variables not set in user distro #822

Open cerebrate opened 2 years ago

cerebrate commented 2 years ago

Windows build number:

22000.856

Your Distribution version:

Debian unstable

Your WSL versions:

WSL version: 0.66.2.0 Kernel version: 5.15.57.1 WSLg version: 1.0.42 MSRDC version: 1.2.3401 Direct3D version: 1.606.4 DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Windows version: 10.0.22000.856

Steps to reproduce:

Issue is apparent immediately upon opening any distribution.

  1. Open an installed Linux distro in Terminal or Command Prompt.
  2. Run env.

WSL logs:

pulseaudio.log stderr.log weston.log

WSL dumps:

No response

Expected behavior:

Listing of environment variables should include those provided by WSLg, to wit:

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

and GUI and sound-using apps should function normally,

Actual behavior:

Above-listed environment variables are not present, and GUI and sound-using apps therefore do not function. (Note: these are present in the system distribution; just not the user one.)

This is purely an issue with the environment variables, however. The WSLg filesystem is properly mounted, sockets are present, etc,, and manually setting the variables with:

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

permits WSLg to function normally.

Biswa96 commented 2 years ago

It's working fine in my system. Here are the screenshots.

user

system

Make sure GUI and system distro related options are not disabled in .wslconfig or .wslgconfig file. Or check if any program or script overwriting those environment variables.

cerebrate commented 2 years ago

As far as I know, there are no such options disabling things:

.wslconfig:

[wsl2]
nestedVirtualization = true
kernel = C:\\ProgramData\\WSL-Kernel\\kernel
networkingMode = bridged
vmSwitch = Bridge
ipv6 = true
debugConsole = false

.wslgconfig:

[system-distro-env]
WESTON_RDP_DISABLE_FRACTIONAL_HI_DPI_SCALING=false

;start menu with distro name
WESTON_RDPRAIL_SHELL_DISABLE_APPEND_DISTRONAME_STARTMENU=true

;restart weston compositor and Xwayland by Left-Ctrl + Left-Atl + Backspace
WESTON_RDPRAIL_SHELL_ALLOW_ZAP=true

wsl.conf:

# Enable extra metadata options by default
[automount]
enabled = true
options = "metadata,umask=022,fmask=022"
crossDistro = true
[network]
generateResolvConf = true
generateHosts = true
[user]
default=avatar

And the issue persists both across distributions (I have an secondary Alpine distribution to use for debugging), and if I bypass all my usual startup scripts with wsl sh . Or even just wsl env:

HOSTTYPE=x86_64
LANG=en_US.UTF-8
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files/WindowsApps/Microsoft.PowerShell_7.2.6.0_x64__8wekyb3d8bbwe:/mnt/c/Program Files/AdoptOpenJDK/jre-16.0.1.9-hotspot/bin:/mnt/c/ProgramData/Boxstarter:/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath:/mnt/c/Program Files (x86)/Microsoft SDKs/Azure/CLI2/wbin:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/Program Files/dotnet/:/mnt/c/Program Files/Microsoft SQL Server/130/Tools/Binn/:/mnt/c/Program Files/Amazon/AWSCLIV2/:/mnt/c/Program Files (x86)/Microsoft SQL Server/150/DTS/Binn/:/mnt/c/Program Files/Calibre2/:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files/Azure Data Studio/bin:/mnt/c/Users/avatar/AppData/Local/Packages/PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0/LocalCache/local-packages/Python39/Scripts:/mnt/c/HashiCorp/Vagrant/bin:/mnt/c/Program Files/Microsoft SQL Server/140/Tools/Binn/:/mnt/c/Program Files/Microsoft SQL Server/150/Tools/Binn/:/mnt/c/Program Files (x86)/GnuPG/bin:/mnt/c/tools/gsudo/Current:/mnt/c/Program Files/GitHub CLI/:/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn/:/mnt/c/Program Files/Git/cmd:/mnt/c/Users/avatar/AppData/Local/Programs/Python/Python38/Scripts/:/mnt/c/Users/avatar/AppData/Local/Programs/Python/Python38/:/mnt/c/Users/avatar/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/avatar/AppData/Local/GitHubDesktop/bin:/mnt/c/Users/avatar/AppData/Local/Microsoft/WindowsApps:/mnt/c/Program Files/Oracle/VirtualBox:/mnt/c/Users/avatar/.dotnet/tools:/mnt/c/Users/avatar/.dotnet/tools:/mnt/c/Users/avatar/AppData/Local/Keybase/:/mnt/c/Users/avatar/AppData/Local/JetBrains/Toolbox/scripts:/mnt/c/Program Files/PowerShell/Modules/Pscx/4.0.0/Apps
TERM=xterm-256color
WSLENV=WT_SESSION::WT_PROFILE_ID
WT_SESSION=df416191-d76b-4074-b539-a9cf250b0d24
WT_PROFILE_ID={574e775e-4f2a-5b96-ac1e-a2962a402336}
WSL_INTEROP=/run/WSL/17498_interop
NAME=pallas
HOME=/home/avatar
USER=avatar
LOGNAME=avatar
SHELL=/usr/bin/zsh
WSL_DISTRO_NAME=Debian
SHLVL=0
PWD=/mnt/c/Users/avatar
OLDPWD=/mnt/c/Users/avatar
_=/usr/bin/env