Reputation: 706
Somehow when I run code .
inside the WSL, it simply doesn't do anything. If I which code
it does return the VS Code path on windows, but still nothing happens.
Upvotes: 6
Views: 29126
Reputation: 1
The following steps worked for me:
Run the following command inside WSL to check if VS Code is installed:
code --version
If this gives an error, install VS Code Server inside WSL:
wget -qO- https://aka.ms/install-vscode-server/setup.sh | bash
If VS Code is installed but still not working, try reinstalling the remote:
rm -rf ~/.vscode-server
rm -rf ~/.vscode
code .
Upvotes: 0
Reputation: 500
It caused by connecting between VScode and WSL.
But you made WSL state mirrored, so ensure make port allow.
sudo ufw allow 60700:60799/tcp
60700 ~ 60799 are ports that VScode uses.
It works for me.
Upvotes: 1
Reputation: 11
The top answer solved my issue, thanks to @rrmesquita. I cannot upvote or comment yet so I thought I'd add some further information that may be useful to those wanting to troubleshoot if it is happening frequently to them.
What I believe caused this issue for me was when the latest Feb 2024 update of Windows VS Code IDE occurred but somehow the associated update of WSL ~/.vscode-server
did not occur when I next launched $ code <my.code-workspace>
from my WSL dev directory. What I think triggered the issue was during performing a restart on my PC after a driver update the shutdown process impacted an in-progress background VS Code update. When everything came back up the end-to-end integration between WSL and VS Code was broken. Probably shouldn't have my work running when messing with windows updates ;-p
Symptoms:
code
did NOT launch the IDE in Windowsvscode-remote://wsl%2Bubuntu/home/<user>/<dev-directory>/<previously-opened-file.ext>
which code
resolving correctly via /mnt/c/Users/<user>/AppData/...
Solution as per top answer, deleting $ rm -r ~/.vscode-server
meant that the next invocation of $ code <my.code-workspace>
downloaded the latest vs code server presumably aligned to latest VS Code WSL extension.
Upvotes: 1
Reputation: 706
After some research, what really fixed the issue for me was this:
rm -r ~/.vscode-server
to delete the VS Code WSL server.wsl --shutdown
.Then you can go back to WSL and run code .
and it should work normally.
Upvotes: 42
Reputation: 21
Another cause of this issue is if VS Code's bin directory isn't in your Windows Path.
You can check if VS Code is in your path correctly by attempting to launch it by typing "code" from a Command Prompt or Power Shell. If you can't launch from these then your Windows path to VS Code is missing or incorrect.
To fix this, first locate your install path for VS Code.
Upvotes: 0
Reputation: 412
I solved it following this post with slight modifications.
wsl --shutdown
code .
starts VS Code for meNote: the issue appeared for me after upgrading to wsl2
Upvotes: 5