Reputation: 179
I'm using VS Code with WSL. To edit code in WSL, I need to navigate to the directory in WSL and then type code .
to open VS Code in the same directory. It was working before, but all of a sudden I can't get this command to work. I get the error zsh: command not found: code
.
Things I have tried:
Upvotes: 5
Views: 6075
Reputation: 13
Steps:
Upvotes: 1
Reputation: 309
For anyone searching for Ubuntu 20.04 I had to do the following:
To check the correct path you can
ls /usr/share/code/code
If the above returns error like this:
# ls: cannot access '/usr/share/code/codes': No such file or directory
Open VS Code directly then check htop to see the actual path VS Code is running
htop
Then run the following with the correct path, mine is /usr/share/code/code
now
sudo ln -s /usr/share/code/code /usr/bin/code
Upvotes: 3
Reputation: 226
I have faced this problem previously. Setting up the environment variable helped me resolve this issue.
Set the environment variable to the path where binary of VS Code is located at as follows: WSL_Environment_Variable_Path_Set
This video - https://www.youtube.com/watch?v=KcFv4QesrR0, contains detailed steps for the same. Also it covers some more tips and tricks that a developer should know about WSL.
Upvotes: 5