7
votes

I am trying to run a Python project on the WSL (Ubuntu-18.04 distribution) system with VS code. I have the WSL - Remote plugin v0.39.9 installed. When run the command:

code .

Receive the error:

/home/username/.vscode-server/bin/6ab598523be7a800d7f3eb4d92d7ab9a66069390/bin/code: 12: /home/username/.vscode-server/bin/6ab598523be7a800d7f3eb4d92d7ab9a66069390/bin/code: /home/username/.vscode-server/bin/6ab598523be7a800d7f3eb4d92d7ab9a66069390/node: Exec format error

When I ran inside the VS Code trying to connect to the WSL instance:

Starting VS Code Server inside WSL (Ubuntu-18.04) Extension version: 0.39.9, Windows build: 18362. Multi distro support: enabled. WSL path support: enabled VS Code Server for WSL closed unexpectedly.

This is the information of VS Code:

Version: 1.39.2 (user setup)
Commit: 6ab598523be7a800d7f3eb4d92d7ab9a66069390
Date: 2019-10-15T15:35:18.241Z
Electron: 4.2.10
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Windows_NT x64 10.0.18362
2
Are you using stable version of VSCode? Did you try with VSCode insider builds? Can you check the node file is a ELF 64 binary with file command? Also is it has a executable flag chmod +x?Biswapriyo
@Biswapriyo, please see the update with the VS code version information. Forgive me I´m newbie, how can I find the node file that you refer?Joseph
Yes, this file has the executable permissions for Owner, Group and Everyone, -rwxr-xr-x. I see two folders inside the bin folder: 6ab598523be7a800d7f3eb4d92d7ab9a66069390 and f06011ac164ae4dc8e753a3fe7f9549844d15e35Joseph
There is risk to take, delete the folder /home/username/.vscode-server/. VSCode remote extension will automatically install it in WSL.Biswapriyo
@Biswapriyo This did not work :-(Jean-Philippe Martin

2 Answers

11
votes

I solved this problem by shutting down wsl and then restarting it in powershell.

wsl --shutdown
wsl
0
votes

Can the problem be that you have an outdated VS Code Server on your WSL and have docker (instead of a Linux version) selected as your default WSL distro?

Solution:

1. Open PowerShell and run wsl -l -v And check that an asterisk * indicates that Ubuntu (or other Linux distro) is your default WSL distro.

* Ubuntu-20.04           Running         2
  docker-desktop-data    Running         2
  docker-desktop         Running         2

If not, run in PowerShell wslconfig /setdefault <Your WSL Linux distro>

2. When you have the correct WSL distro selected, open VSCode, press Ctrl+Shift+P, and type Remote-WSL: New WSL Window. This will update VS Code Server on your WSL Linux distro.

3. code . should now work in WSL

I had a similar problem that occurred after updating VSCode. I recognized it when I tried to open VSCode from Ubuntu and received the following error:

~$ code .
Updating VS Code Server to version 507ce72a4466fbb27b715c3722558bb15afa9f48
Removing previous installation...
Installing VS Code Server for x64 (507ce72a4466fbb27b715c3722558bb15afa9f48)
Downloading: 100%
Failed
--2021-06-29 10:48:51--  https://update.code.visualstudio.com/commit:507ce72a4466fbb27b715c3722558bb15afa9f48/server-linux-x64/stable
Resolving update.code.visualstudio.com (update.code.visualstudio.com)... failed: Temporary failure in name resolution.
wget: unable to resolve host address ‘update.code.visualstudio.com’
ERROR: Failed to download https://update.code.visualstudio.com/commit:507ce72a4466fbb27b715c3722558bb15afa9f48/server-linux-x64/stable to /home/username/.vscode- server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48-1624952921.tar.gz