Search code examples
visual-studio-codewindows-subsystem-for-linux

VS Code remote to WSL /bin/code-server: not found


I have recently moved my WSL installation to another drive for disk space sake by using this guide: medium.

After it, when I try to open a remote window on VS Code I get the error:

/mnt/c/Users/User/.vscode/extensions/ms-vscode-remote.remote-wsl-0.88.2/scripts/wslServer.sh: 50: /root/.vscode-server/bin/dc96b837cf6bb4af9cd736aa3af08cf8279f7685/bin/code-server: not found

Actually on /root/.vscode-server there is no bin directory but I cannot get why.

By using WSL from a windows prompt it opens normally.

What I messed up?


Solution

  • TLDR: just rename or delete the .vscode-server/ folder in your wsl distro, it must be in the root, otherwise when connecting to wsl, vscode would attempt to install itself on you wsl distro.

    I came across a similar situation, I did have the .vscode-server/ folder in the root though.

    ATENTION: What I did made me lose my vscode extensions installed in wsl, wasn't a big deal for me but may be for your case.

    To solve my issue:

    • I opened the terminal in the wsl distro I was using for vscode;
    • Checked if i had the folder by running the commandcd ~/.vscode-server;
    • I did have it, so I just renamed it (non destructive) to ".old_vscode-server";
    • Then just opened a new vscode instance and connected to wsl, it installed vscode server again, but without my previous extensions;