Programs cannot get environment variables from wsl
Answered
I'm using Xming to get GTK gui and have to set env var "DISPLAY" in WSL.
However, Clion use "wsl --exec /bin/bash -c" to run compiled programs and this shell cannot get "DISPLAY".
I have tryed to set this env var in etc/environment, in bashrc(before "case $-"). But all failed.
Terminal of clion could run my program and read value of DISPLAY. Now I have to build by ctrl+f9 and run in terminal.
When I run "wsl --exec /bin/bash -c env" in windows terminal, I noticed that there is no DISPLAY and this shell have a shlvl as 0.
BTW, run "bash -c env" in WSL will list DISPLAY as a env var, which confused me. Maybe this issue should be report to microsoft, not jetbrain?
Any help is appreciated.
Please sign in to leave a comment.
Hello!
Please once again try to set the variable in .bashrc, and in CLion go to `File | Settings | Advanced Settings` and enable the "Execute commands in login (-l) shell" option (see this comment). Does it help?
Thanks! This works perfectly!