WSL2 terminal does not recognize Visual Studio Code

kDar picture kDar · Sep 10, 2019 · Viewed 8.3k times · Source

When I try to execute code from WSL, like this:

cmd.exe
wsl code .

I get the following error:

/bin/bash: code: command not found

However, if I execute the same command but first run cmd.exe as an Administrator, vscode opens as expected.

The question is why "code" is not recognizable when I run as non-admin, and how can I solve it?

Additional info: WSL2 version 41959 vscode version 1.38 vscode Remote WSL extension version 0.39.5

Answer

kDar picture kDar · Sep 11, 2019

As @Biswapriyo mentioned, this is an open bug where WSL cannot access Windows C drive. Workaround that helped me is to restart WSL like this:

wsl --shutdown
wsl