I use Windows Subsystem Linux(Ubuntu 18.04) in my Win10, and I install a Maven in it.
Besides, I install a maven in Win10 before.
Now when I used mvn compile
in WSL, it told me that maven compile fail.
I use which mvn
and find that it references to the Maven installed in Win10.
Besides, I run env
and find that Win10's Path is added to the WSL's Path.
I don't want to use any thing in Win10's Path when I use WSL, how should I do?
For Windows build LOWER than 17713: WSL uses WSL_DISTRIBUTION_FLAGS Enumeration to configure its behavior and interoperability between Windows and Linux side. Here is the code snippet from
wslapi.h
header file.At first launch, WSL uses the default flag = 0x7 (i.e. 0+1+2+4). If that flag = 0x5 (i.e. 0+1+4) Windows NT path will not appended in
$PATH
environment variable. So, how to find that flags registry value? OpenHKCU\Software\Microsoft\Windows\CurrentVersion\Lxss
registry path in Registry Editor aka.regedit.exe
. Open each subkey with UID values and matchDistributionName
with your installed distribution name. Then edit/add theFlags
DWORD registry value to0x5
.For Windows build HIGHER than 17713: In new build WSL uses
wsl.conf
file to configure its behavior and interoperability between Windows and Linux side. Thatwsl.conf
file follows INI file format. Runwsl.exe
orbash.exe
. Create a file/etc/wsl.conf
. Then add the following interop section with any text editor in Linux.Save that file and exit from
wsl.exe
. Now whenever WSL is executed Windows paths will not appended to Linux$PATH
environment variable.