So I had written a big answer on this and for some reason I can't find it. I don't know if it didn't get posted or what happened. So re-writing what I written earlier
Windows and Windows Sub System Linux do not by default share any environment variables as such. But there is a way to automatically share variables between the two as explained in below article
https://blogs.msdn.microsoft.com/commandline/2017/12/22/share-environment-vars-between-wsl-and-windows/
By default your c:\
gets mapped to /mnt/c
. Now you have two options
Shell Environments
You can update your ~/.bashrc
or ~/.bash_profile
(whichever you use) and export the variables
export ANDROID_HOME="/mnt/c/Android/sdk"
export PATH="$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools"
Shared Environment
Windows created a special environment variable named WSLENV
. This environment variable can be used to share the variable between two environments and it will also auto translates paths. Before we dive in some special flags
- /p: This flag indicates that a path should be translated between WSL paths and Win32 paths.
- /l: This flag indicates the value is a list of paths. In WSL, it is a colon-delimited list. In Win32, it is a semicolon-delimited list.
- /u: This flag indicates the value should only be included when invoking WSL from Win32. In the example below, we set FORWSL from cmd and it will show up in WSL.
- /w: This flag indicates the value should only be included when invoking Win32 from WSL.
Now if you set the environment like below
WSLENV=ANDROID_HOME/p
Above says the ANDROID_HOME
should be shared between WSL and Windows and the /p
indicates that it should be shared automatically. This is the recommended way of doing it to keep everything in sync