2

I'm using WSL2 with the Remote - WSL extension for Visual Studio Code. If I do code ., Visual Code opens in the specified folder. However, if I change user with su, the same command outputs:

Command 'code' not found, did you mean:
...
NotTheDr01ds
  • 15,620
  • 5
  • 44
  • 70
betus
  • 93
  • 6

1 Answers1

1

You seem to be running into this issue, where the Remote extension always uses the default user.

While no solution here is ideal, there are (at least) three options, depending on your exact use-case:

  • Temporarily change the default user:

    You'll need to sudo -e /etc/wsl.conf and add:

    [user]
    default=other_username
    

    Then wsl --terminate <distro> (from PowerShell, CMD, or the Start menu), then restart.

  • Use two different WSL instances with different default users in each one.

  • Possibly, give your default user permissions to whatever files you are trying to edit for the other user.

NotTheDr01ds
  • 15,620
  • 5
  • 44
  • 70