Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
@useraccessdenied
Copy link

useraccessdenied commented May 29, 2020

Exiting and relaunching doesn't update changes in wsl.conf. Terminating WSL from PowerShell using wslconfig /t Ubuntu command works. I am on WSL2 currently.

@takizo
Copy link

takizo commented Aug 11, 2020

Exiting and relaunching doesn't update changes in wsl.conf. Terminating WSL from PowerShell using wslconfig /t Ubuntu command works. I am on WSL2 currently.

Alternatively can use wsl --shutdown in cmd

@ShivKJ
Copy link

ShivKJ commented Jul 10, 2021

Thanks @takizo. That worked for me,

@moracabanas
Copy link

moracabanas commented Sep 24, 2021

I need to WSL2 interop to run code . but the excess of /mnt/c directories from windows in Ubuntu WSL2 PATH leads to slow python runs.
So how could I manually edit appendWindowsPath so I can run code . and just that?

@stevenli6186
Copy link

stevenli6186 commented Oct 10, 2021

This doesn't work at all for me... can you guys provide specific beginner instructions?

@useraccessdenied
Copy link

useraccessdenied commented Oct 11, 2021

This doesn't work at all for me... can you guys provide specific beginner instructions?

ELI5 instructions: open /etc/wsl.conf in text editor which is present in wsl distro. If the file is not present in etc directory, create it. And only put this there.

[interop]
appendWindowsPath = false

Else modify the above line if it exists. Then do wslconfig /t Ubuntu or wsl --shutdown or simply reboot the pc.

@stevenli6186
Copy link

stevenli6186 commented Oct 11, 2021

that also did not work for me...

What I had to do as edit my .bashrc file and add export PS1="\u@\h: "

@useraccessdenied
Copy link

useraccessdenied commented Oct 11, 2021

How did modifying PS1 worked for you? It does entirely different thing.

@xsrvmy
Copy link

xsrvmy commented Nov 30, 2021

@moracabanas One way would be to run which code to find where it is, then to add an alias to it.

@robertmoelker
Copy link

robertmoelker commented Jan 3, 2022

@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

skyleaworlder commented May 9, 2022

Thanks. Still a hero in 2022. @takizo

@GavinRay97
Copy link

GavinRay97 commented Oct 27, 2022

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"

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