When I try open VS Code in WSL2 Terminal, like this:
code .
I get the following error:
mkdir: cannot create directory {DIRECTORY} : Permission denied
When started with sudo:
sudo: code: command not found
I added VS Code to my PATH on Windows, and installed WSL-Remote
I am working on:
Alternatively, you can open a Remote WSL window directly from VS Code: Start VS Code. Press F1, select Remote-WSL: New Window for the default distro or Remote-WSL: New Window using Distro for a specific distro. Use the File menu to open your folder.
Visual Studio's WSL 2 toolset allows you to use Visual Studio to build and debug C++ code on WSL 2 distros without adding a SSH connection. You can already build and debug C++ code on WSL 1 distros using the native WSL 1 toolset introduced in Visual Studio 2019 version 16.1.
Check the configure file(/etc/sudoers
), you need to modify the secure_path
to enable run VS code with sudo command.
Also, it is better if you put the command path into /etc/profile, so every user could run VS 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