I want to use Visual Studio Code
already installed on Windows for WSL2 (I use ubuntu app on Microsoft Store). When I cd
into the directory to use and type code .
then show an error message
To use Visual Studio Code with the Windows Subsystem for Linux, please install Visual Studio Code in Windows and uninstall the Linux version in WSL. You can then use the
code
command in a WSL terminal just as you would in a normal command prompt.
I have installed Remote - WSL
plugin on Visual Studio Code and it works but can't open Visual Studio Code on ubuntu app.
I solved my problem, the cause is same as in messeage:
To use Visual Studio Code with the Windows Subsystem for Linux, please install Visual Studio Code in Windows and uninstall the Linux version in WSL. You can then use the
code
command in a WSL terminal just as you would in a normal command prompt.
I installed extra Visual Studio Code
on ubuntu app (this is not necessary) so when i type code .
the system will understand that I'm using Visual Studio Code
already installed on ubuntu app
I uninstall Visual Studio Code
on ubuntu app by
sudo dpkg --purge code
rm -rf ~/.vscode
Note: make sure that the default of wsl is now ubuntu app, otherwise use the following command:
wsl -s Ubuntu-20.04
Then I typed code .
on ubuntu app it actually opened Visual Studio Code
on Windows for me.
Thanks for Watching!
If you've just installed vscode in Windows, you'll likely need to logout/in before the environment changes will be picked up so that you can use code
in wsl/Ubuntu.
Another gotcha to lookout for is that VSCode insiders is launched with code-insiders
not code
. If that's your scenario, then use the following to create a softlink named code
that will call code-insiders
.
ln -s "$(which code-insiders)" ~/.local/bin/code
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With