skip to Main Content

My computer crashed and I had to reinstall my system today.
I’m running Windows 10 with VS Code and I’m using Debian (WSL) as my main terminal.

I have installed VS Code with the "Add to PATH" option and I have activated the Windows Subsystem for Linux in PowerShell.

I can use the command "code" in CMD and PowerShell but when I try to run it in Debian I get
"-bash: code: command not found", as far as I understand it should work straight away when installing with the "path" option? At least according to this article: https://dev.to/ajeet/the-ultimate-guide-to-use-vs-code-with-windows-subsystem-for-linux-wsl-51hc

I have also tried installing the "Remote Development" extension, but I’m still facing the same problem.

3

Answers


  1. Try adding the following line to the .bashrc file in your $HOME directory (~/.bashrc).

    PATH=$PATH:/mnt/c/Users/$USER/AppData/Local/Programs/Microsoft VS Code/bin
    

    Where you replace $USER with your Windows username.

    Login or Signup to reply.
  2. Alternatively, you can create an alias and add it to your .bashrc file:

    alias $COMMAND"$PATH"
    

    Where you replace $COMMAND with a name of your choice and $PATH with the path to the executable.

    Login or Signup to reply.
  3. You can set an alias in bashrc like:

    alias code='code --remote wsl+<distro_name>'
    

    Where distro_name is your WSL distro name.

    You can check your distro name in PowerShell by using:

    wsl --list
    

    Refer to the documentation.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search