Replies: 7 comments
-
AFAIK, it is same in WSL2. |
Beta Was this translation helpful? Give feedback.
-
@Biswa96 Thank you for your prompt reply. I have tried:
I have no idea about what have I done wrong? My purpose is to access $OneDrive from within Ubuntu in order to bind mount it into Docker container. |
Beta Was this translation helpful? Give feedback.
-
What I understand is that you want to pass an environment variable from Windows to WSL. Then the correct flag might be
C:\> set WSLENV=USERPROFILE/u
$ env | grep -i user
USERPROFILE=C:\Users\x
USER=x
WSLENV=USERPROFILE/u |
Beta Was this translation helpful? Give feedback.
-
@Biswa96 I can confirm that your solution works but constrained in one single session. For example, open cmd.exe first, set WSLENV as you did. I have to run But if I open another terminal , I can no loager access the variable. No need to say availability across system reboot. Maybe any suggestion about the variable persistence? On the other hand, we can't set WSLENV from PowerShell, can we? |
Beta Was this translation helpful? Give feedback.
-
Mine was just an example. To make the variable persistant, you need to use setx command or control panel's advanced system settings. The article already mentioned that. |
Beta Was this translation helpful? Give feedback.
-
Here are what I have found today.
The correct way to share
No double qoutes around the variable allowed here or include entire
So if I want to share both But I still have trouble when I want to append new variable to existing
It will add prefiex Any suggestions? |
Beta Was this translation helpful? Give feedback.
-
To set it in Powershell use: [Environment]::SetEnvironmentVariable("WSLENV", $env:WSLENV + "USERPROFILE/p:", [System.EnvironmentVariableTarget]::User) |
Beta Was this translation helpful? Give feedback.
-
I am looking for some way to share environment between WSL2 and host machine - Windows 10.
I checked this article until I found it is WSL related instead of WSL2.
Do you have any advices how to do this in WSL2 ?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions