How to remove the Win10's PATH from WSL

前端 未结 3 807
刺人心
刺人心 2020-12-25 13:25

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

3条回答
  •  长发绾君心
    2020-12-25 13:59

    Modifying the Flags attribute in the Windows Registry still works with WSL 2. It worked fine for me and didn't cause any issues whatsoever. The only difference is that the initial Flags value in my case was 0x0F (= 15). Changing that to 0x0D (= 13) prevents appending the Windows %PATH% to the Ubuntu $PATH.

    You can still find all WSL 2 distributions in the Registry under HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\. Each distribution has its own GUID subfolder, looking something like

    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\
        |
        |-- {40db8e6f-0520-4ffffd-9c8b-0f5414e685c9}
        |-- {6a61345d-2dc6-4b9e-abb1-28a26d64e19f}
        |-- {bce2f98a-b234-4749-adbe-7311df078d26}
        |-- ...
        |-- {ea808e4e-dc24-4645-aed0-ebd67c871e01}
    
    

    Of course, your GUIDs will be different from mine.

    By clicking on each of the GUIDs and looking at the DistributionName attribute you can find out which GUID refers to what WSL 2 distribution, see (1) in screenshot below. And then simply modify the Flags value and set it to 13, see (2) in screenshot. If the value in the Flags attribute is different from 0x0F it shouldn't matter, just reduce it by 2 and you should be fine.

提交回复
热议问题