Open seokbeomKim opened 11 months ago
If you're able to access these variables without a quote, meaning you can echo $WT_SESSION
and see the value, then that means the quote is not in the name. Are you sure the quote is in the name?
Also would be curious to see what the output of xargs -0 -L1 -a /proc/self/environ
looks like. The fact that you can read out the variables without the quote makes me question if the quote is actually in the name.
Do xargs -0 -L1 -a /proc/self/environ
sukbeom@LAPTOP-R4FQS2C5:~$ xargs -0 -L1 -a /proc/self/environ
'WSL_INTEROP=/run/WSL/1540_interop'
'WSL_DISTRO_NAME=Ubuntu-22.04'
'DISPLAY=:0'
'WT_SESSION=0389944a-6b92-4dc6-8e9b-973324383795'
'WT_PROFILE_ID={d7b20cea-47a9-518c-95a4-c8bd91e2e1c6}'
'WSLENV=WT_SESSION:BASH_ENV/u:WT_PROFILE_ID'
'PULSE_SERVER=unix:/mnt/wslg/PulseServer'
'PWD=/home/sukbeom'
'TERM=xterm-256color'
'WSL2_GUI_APPS_ENABLED=1'
'XDG_RUNTIME_DIR=/mnt/wslg/runtime-dir'
'WAYLAND_DISPLAY=wayland-0'
'HOSTTYPE=x86_64'
SHELL=/bin/bash
SUDO_GID=1000
WSL_DISTRO_NAME=Ubuntu-22.04
SUDO_COMMAND=/usr/sbin/enter-systemd-namespace
SUDO_USER=sukbeom
PWD=/home/sukbeom
LOGNAME=sukbeom
XDG_SESSION_TYPE=tty
echo $WT_SESSION
=> Nothing shows up
sukbeom@LAPTOP-R4FQS2C5:~$ echo $WT_SESSION
3. Evaluate related variables:
sukbeom@LAPTOP-R4FQS2C5:~$ for l in $(env | grep -E ^\' | sed -e "s/^'(..)=../\1/g"); do echo "variable $l: " $(printenv $l); done variable WSL_INTEROP: /run/WSL/1540_interop variable WSL_DISTRO_NAME: Ubuntu-22.04 variable DISPLAY: 172.29.112.1:0.0 variable WT_SESSION: variable WT_PROFILE_ID: variable WSLENV: WT_SESSION:BASH_ENV/u:WT_PROFILE_ID variable PULSE_SERVER: variable PWD: /home/sukbeom variable TERM: xterm-256color variable WSL2_GUI_APPS_ENABLED: variable XDG_RUNTIME_DIR: /run/user/1000 variable WAYLAND_DISPLAY: variable HOSTTYPE:
4. I'd like to know where these variables are set from. Could you give me some hints to figure it out?
In the case of the variable $DISPLAY, the bash is going to set it to export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0
by my .bashrc
. But.. it seems like starting WSL console is setting DISPLAY to initial value :0
containing the quote character.
sukbeom@LAPTOP-R4FQS2C5:~$ env | grep DISPLAY
'DISPLAY=:0'
'WAYLAND_DISPLAY=wayland-0'
DISPLAY=172.29.112.1:0.0
Sorry for the slow response. Are the environment variables always like this, from the moment you start wsl.exe
?
You can use this to see how many parent processes this comes from.
#!/usr/bin/bash
pid=$$
while [ true ]; do
echo -------- pid: $pid $(sudo cat "/proc/${pid}/cmdline" | tr -d '\0') ------------
sudo xargs -0 -L1 -a "/proc/$pid/environ"
echo ---------------------------------------------------------
if [ $pid == 1 ]; then exit 0; fi
pid=$(($(ps -o ppid= -p $pid)))
done
I will add a comment by today. Can I reopen this issue?
No worries, I re-opened it.
Are the environment variables always like this, from the moment you start wsl.exe? => Yes.
I got the output of the script and there was a point:
pid: 2366 /bin/login-p-f'DISPLAY=:0''HOSTTYPE=x86_64''PULSE_SERVER=unix:/mnt/wslg/PulseServer''PWD=/home/sukbeom''TERM=xterm-256color''WAYLAND_DISPLAY=wayland-0''WSL2_GUI_APPS_ENABLED=1''WSLENV=WT_SESSION:WT_PROFILE_ID:BASH_ENV/u''WSL_DISTRO_NAME=Ubuntu-22.04''WSL_INTEROP=/run/WSL/2406_interop''WT_PROFILE_ID={d7b20cea-47a9-518c-95a4-c8bd91e2e1c6}''WT_SESSION=4e9a7bb1-2d31-4af6-91d0-ad2b210d727e''XDG_RUNTIME_DIR=/mnt/wslg/runtime-dir' ------------
The full log:
-------- pid: 5645 /usr/bin/bash./231108_test.sh ------------
'WSL_INTEROP=/run/WSL/2406_interop'
'WSL_DISTRO_NAME=Ubuntu-22.04'
'DISPLAY=:0'
'WT_SESSION=4e9a7bb1-2d31-4af6-91d0-ad2b210d727e'
'WT_PROFILE_ID={d7b20cea-47a9-518c-95a4-c8bd91e2e1c6}'
'WSLENV=WT_SESSION:WT_PROFILE_ID:BASH_ENV/u'
'PULSE_SERVER=unix:/mnt/wslg/PulseServer'
'PWD=/home/sukbeom'
'TERM=xterm-256color'
'WSL2_GUI_APPS_ENABLED=1'
'XDG_RUNTIME_DIR=/mnt/wslg/runtime-dir'
'WAYLAND_DISPLAY=wayland-0'
'HOSTTYPE=x86_64'
SHELL=/bin/bash
SUDO_GID=1000
WSL_DISTRO_NAME=Ubuntu-22.04
SUDO_COMMAND=/usr/sbin/enter-systemd-namespace
SUDO_USER=sukbeom
PWD=/home/sukbeom/workspace/issues/wsl_10476
LOGNAME=sukbeom
XDG_SESSION_TYPE=tty
GIT_SSL_NO_VERIFY=1
MOTD_SHOWN=pam
HOME=/home/sukbeom
LANG=C.UTF-8
WSL_INTEROP=/run/WSL/2406_interop
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
LESSCLOSE=/usr/bin/lesspipe %s %s
XDG_SESSION_CLASS=user
TERM=xterm-256color
LESSOPEN=| /usr/bin/lesspipe %s
USER=sukbeom
DISPLAY=172.29.112.1:0.0
SHLVL=1
XDG_SESSION_ID=2
XDG_RUNTIME_DIR=/run/user/1000
WSLENV=WT_SESSION:WT_PROFILE_ID:BASH_ENV/u
LC_ALL=en_US.UTF-8
XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share:/usr/share:/var/lib/snapd/desktop
HUSHLOGIN=FALSE
BROWSER=wslview
PATH=/home/sukbeom/.local/bin:/home/sukbeom/bin:/home/sukbeom/opt/leetcode_cli:/home/sukbeom/opt/bin:/home/sukbeom/.cargo/bin:/home/sukbeom/go/bin:/home/sukbeom/.config/emacs/bin:/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/OpenSSH/:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/Program Files/OpenSSH:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files/dotnet/:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/Program Files/Microsoft SQL Server/120/Tools/Binn/:/mnt/c/Program Files/usbipd-win/:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/gsudo/Current:/mnt/c/Program Files/nodejs/:/mnt/c/Program Files/PowerShell/7/:/mnt/c/Program Files (x86)/Atmel/sam-ba_2.18/drv/:/mnt/c/Program Files (x86)/Atmel/sam-ba_2.18:/mnt/c/Program Files/OpenSSH:/mnt/c/Users/chaox/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/chaox/AppData/Local/Programs/oh-my-posh/bin:/mnt/c/Users/chaox/AppData/Local/Programs/oh-my-posh/themes:/mnt/c/Users/chaox/AppData/Local/Programs/Hyper/resources/bin:/mnt/c/Program Files/qemu:/mnt/c/MentorGraphics/9.5PADS/SDD_HOME/common/win32/lib:/mnt/c/Utilities/Fwdn:/mnt/c/Users/chaox/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/chaox/AppData/Roaming/npm:/snap/bin
SUDO_UID=1000
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
MAIL=/var/mail/sukbeom
OLDPWD=/home/sukbeom/workspace
_=./231108_test.sh
---------------------------------------------------------
-------- pid: 2402 -bash ------------
SUDO_GID=1000
WSL_DISTRO_NAME=Ubuntu-22.04
SUDO_COMMAND=/usr/sbin/enter-systemd-namespace
SUDO_USER=sukbeom
PRE_NAMESPACE_PWD=/home/sukbeom
PWD=/home/sukbeom
LOGNAME=sukbeom
LANG=C.UTF-8
WSL_INTEROP=/run/WSL/2406_interop
TERM=xterm-256color
USER=sukbeom
DISPLAY=:0
SHLVL=0
WSLENV=WT_SESSION:WT_PROFILE_ID:BASH_ENV/u
LC_ALL=en_US.UTF-8
SUDO_UID=1000
PRE_NAMESPACE_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/OpenSSH/:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/Program Files/OpenSSH:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files/dotnet/:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/Program Files/Microsoft SQL Server/120/Tools/Binn/:/mnt/c/Program Files/usbipd-win/:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/gsudo/Current:/mnt/c/Program Files/nodejs/:/mnt/c/Program Files/PowerShell/7/:/mnt/c/Program Files (x86)/Atmel/sam-ba_2.18/drv/:/mnt/c/Program Files (x86)/Atmel/sam-ba_2.18:/mnt/c/Program Files/OpenSSH:/mnt/c/Users/chaox/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/chaox/AppData/Local/Programs/oh-my-posh/bin:/mnt/c/Users/chaox/AppData/Local/Programs/oh-my-posh/themes:/mnt/c/Users/chaox/AppData/Local/Programs/Hyper/resources/bin:/mnt/c/Program Files/qemu:/mnt/c/MentorGraphics/9.5PADS/SDD_HOME/common/win32/lib:/mnt/c/Utilities/Fwdn:/mnt/c/Users/chaox/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/chaox/AppData/Roaming/npm
'DISPLAY=:0'
'HOSTTYPE=x86_64'
'PULSE_SERVER=unix:/mnt/wslg/PulseServer'
'PWD=/home/sukbeom'
'TERM=xterm-256color'
'WAYLAND_DISPLAY=wayland-0'
'WSL2_GUI_APPS_ENABLED=1'
'WSLENV=WT_SESSION:WT_PROFILE_ID:BASH_ENV/u'
'WSL_DISTRO_NAME=Ubuntu-22.04'
'WSL_INTEROP=/run/WSL/2406_interop'
'WT_PROFILE_ID={d7b20cea-47a9-518c-95a4-c8bd91e2e1c6}'
'WT_SESSION=4e9a7bb1-2d31-4af6-91d0-ad2b210d727e'
'XDG_RUNTIME_DIR=/mnt/wslg/runtime-dir'
HOME=/home/sukbeom
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
MOTD_SHOWN=pam
MAIL=/var/mail/sukbeom
XDG_SESSION_ID=2
XDG_RUNTIME_DIR=/run/user/1000
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
XDG_SESSION_TYPE=tty
XDG_SESSION_CLASS=user
HUSHLOGIN=FALSE
---------------------------------------------------------
-------- pid: 2366 /bin/login-p-f'DISPLAY=:0''HOSTTYPE=x86_64''PULSE_SERVER=unix:/mnt/wslg/PulseServer''PWD=/home/sukbeom''TERM=xterm-256color''WAYLAND_DISPLAY=wayland-0''WSL2_GUI_APPS_ENABLED=1''WSLENV=WT_SESSION:WT_PROFILE_ID:BASH_ENV/u''WSL_DISTRO_NAME=Ubuntu-22.04''WSL_INTEROP=/run/WSL/2406_interop''WT_PROFILE_ID={d7b20cea-47a9-518c-95a4-c8bd91e2e1c6}''WT_SESSION=4e9a7bb1-2d31-4af6-91d0-ad2b210d727e''XDG_RUNTIME_DIR=/mnt/wslg/runtime-dir' ------------
SHELL=/bin/bash
SUDO_GID=1000
WSL_DISTRO_NAME=Ubuntu-22.04
SUDO_COMMAND=/usr/sbin/enter-systemd-namespace
SUDO_USER=sukbeom
PRE_NAMESPACE_PWD=/home/sukbeom
PWD=/home/sukbeom
LOGNAME=root
HOME=/root
LANG=C.UTF-8
WSL_INTEROP=/run/WSL/2406_interop
TERM=xterm-256color
USER=root
DISPLAY=:0
SHLVL=0
WSLENV=WT_SESSION:WT_PROFILE_ID:BASH_ENV/u
LC_ALL=en_US.UTF-8
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
SUDO_UID=1000
MAIL=/var/mail/root
PRE_NAMESPACE_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/OpenSSH/:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/Program Files/OpenSSH:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files/dotnet/:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/Program Files/Microsoft SQL Server/120/Tools/Binn/:/mnt/c/Program Files/usbipd-win/:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/gsudo/Current:/mnt/c/Program Files/nodejs/:/mnt/c/Program Files/PowerShell/7/:/mnt/c/Program Files (x86)/Atmel/sam-ba_2.18/drv/:/mnt/c/Program Files (x86)/Atmel/sam-ba_2.18:/mnt/c/Program Files/OpenSSH:/mnt/c/Users/chaox/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/chaox/AppData/Local/Programs/oh-my-posh/bin:/mnt/c/Users/chaox/AppData/Local/Programs/oh-my-posh/themes:/mnt/c/Users/chaox/AppData/Local/Programs/Hyper/resources/bin:/mnt/c/Program Files/qemu:/mnt/c/MentorGraphics/9.5PADS/SDD_HOME/common/win32/lib:/mnt/c/Utilities/Fwdn:/mnt/c/Users/chaox/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/chaox/AppData/Roaming/npm
---------------------------------------------------------
-------- pid: 0 ------------
---------------------------------------------------------
-------- pid: 0 ------------
---------------------------------------------------------
-------- pid: 0 ------------
---------------------------------------------------------
Windows Version
Microsoft Windows [Version 10.0.22621.2283]
WSL Version
1.3.17.0
Are you using WSL 1 or WSL 2?
Kernel Version
5.15.90.4-1
Distro Version
Ubuntu 22.04
Other Software
Yocto kirstone. (but this is not the main reason.)
Repro Steps
In the result of
env
command, there are few lines starting/ending with quote character. Even though we can get the environmental variables with 'echo $PWD', this must be fixed.In Yocto project, commands will not normally work due to this. For example, when I do
bitbake -c menuconfig linux-yocto
, the command will exit without any error message. But after I dosh
,bash
,bitbake -c menuconfig linux-yocto
again, the operation will be successful. In the working environment, those problematic variables are not defined.Not only Yocto project, but also many other projects could face unexpected errors due to this.
Expected Behavior
All environment variables must be defined without quote(').
Actual Behavior
Some variables include quote character.
Diagnostic Logs
No response