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
i
sudo nano /etc/wsl.conf
Then add
[interop]
appendWindowsPath = false
then
Ctrl+S
then Ctrl+X
then exit
.
Add the following code to .bashrc
PATH=$(/usr/bin/printenv PATH | /usr/bin/perl -ne 'print join(":", grep { !/\/mnt\/[a-z]/ } split(/:/));')
Alternative (run once!):
echo "export PATH=`echo $PATH | tr ':' '\n' | grep -v /mnt/ | tr '\n' ':'`" >> ~/.bashrc
Alternative 2
Just add export PATH="$PATH:/usr/bin"
to the end of ~/.bashrc
, so that usr/bin
takes precedence over windows' apps. Probably not a good option.
Edit Windows Registry. It is currently not recommended.
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\{GUID}\Flags
Change Flags
from 7
to 5
in order to exclude the WSL_DISTRIBUTION_FLAGS_APPEND_NT_PATH
enum.
Simple reenter WSL and test:
echo $PATH
Run at PowerShell as Admin:
Restart-Service LxssManager
Terminating WSL from PowerShell as Admin using
wslconfig /t Ubuntu
Adapt was your need, Ubuntu-18.04
in my case
References:
https://github.com/microsoft/WSL/issues/1493
https://devblogs.microsoft.com/commandline/automatically-configuring-wsl
https://gist.github.com/ilbunilcho/4280bd55a10cefef75e74986b6bff936