Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ilbunilcho/4280bd55a10cefef75e74986b6bff936 to your computer and use it in GitHub Desktop.
Save ilbunilcho/4280bd55a10cefef75e74986b6bff936 to your computer and use it in GitHub Desktop.
How to remove Windows paths from WSL path

after Build 17093

  • can override settings by edit "/etc/wsl.conf"
  • normally this file is not exists at first
$ sudo vi /etc/wsl.conf

[interop]
appendWindowsPath = false

$ exit
c:\Users\user> wsl

$ echo $PATH

to take effect you should exit and relaunch shell

see also

default wsl.conf settings

[automount]
enabled = true
mountFsTab = true
root = "/mnt/"
options =

[network]
generateHosts = true
generateResolvConf = true

[interop]
enabled = true
appendWindowsPath = true
@robertmoelker
Copy link

@moracabanas You can also just append your VSCode install bin to the PATH in your .zshrc file. That's what I did, and that's working perfectly fine. So first configure the wsl.conf and add the appendWindowsPath = false and then adjust your .zshrc and add the following line;

export PATH="$PATH:/mnt/c/Users/rober/AppData/Local/Programs/Microsoft VS Code/bin"

@zodman
Copy link

zodman commented Feb 19, 2022

I confirm work for wsl2

@andreasrsa
Copy link

andreasrsa commented Feb 20, 2022

I kept the wsl.conf like 1st advised.

[interop]
appendWindowsPath = false

THEN my blond moment elapsed

Powershell 7.2 :

.\wslconfig.exe /l
Windows Subsystem for Linux Distributions:
Ubuntu-20.04 (Default)
'''
./wslconfig /t Ubuntu-20.04

But missed below. After I termiated the service, the wsl.conf file was active. Many Thanks!

The OpenWrt Buildroot Environment works like a charm.

45fd96cb8a7f0897b0d590d95fca4899-30
45fd96cb8a7f0897b0d590d95fca4899-29
!

@skyleaworlder
Copy link

Thanks. Still a hero in 2022. @takizo

@GavinRay97
Copy link

Another way you can configure it globally, for all WSL2 distros, from the Windows $USER/.wslconfig config:

[interop]
appendWindowsPath = false

[boot]
command = export PATH="$PATH:/mnt/c/Users/YOUR_USERNAME/AppData/Local/Programs/Microsoft VS Code/bin"

@YAmikep
Copy link

YAmikep commented Mar 17, 2023

@GavinRay97
Aren't these settings (interop etc) only /etc/wsl.conf settings and not .wslconfig settings? 🤔
See wsl.conf and .wslconfig

@andreasrsa
Copy link

@GavinRay97
Aren't these settings (interop etc) only /etc/wsl.conf settings and not .wslconfig settings? 🤔
See wsl.conf and .wslconfig

Yup, I know docker has a wslcomfig, but it’s not related to this thread regarding the correction of the $PATH

@YAmikep
Copy link

YAmikep commented Mar 18, 2023

It would have been nice to set this up for all distros at once, though.
For now, I'll keep doing it by distro using the /etc/wsl.conf file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment