microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.61k stars 275 forks source link

VSCode failt to install code-server #9541

Open jmservier opened 7 months ago

jmservier commented 7 months ago

Same issue as #1856

Once WSL extensions is installed, and click on connect to Distro, VScode on widows side detect that code-server is not present at ~/.vscode-server/bin/31c37ee8f63491495ac49e43b8544550fbae4533 and then download the archive file. But this archive is corrupted for an unknown reason

I get this logs:

[2024-02-12 09:11:19.643] Extension version: 0.86.0
[2024-02-12 09:11:19.643] L10N bundle: undefined
[2024-02-12 09:11:19.659] authorityHierarchy: wsl+Ubuntu-22.04
[2024-02-12 09:11:19.659] WSL extension activating for a local WSL instance
[2024-02-12 09:11:19.671] Resolving wsl+Ubuntu-22.04, resolveAttempt: 1
[2024-02-12 09:11:19.672] NodeExecServer run: C:\Windows\System32\wsl.exe --status
[2024-02-12 09:11:20.042] WSL feature installed: true (wsl --status)
[2024-02-12 09:11:20.042] NodeExecServer run: C:\Windows\System32\wsl.exe --list --verbose
[2024-02-12 09:11:20.362] 1 distros found
[2024-02-12 09:11:20.364] Starting VS Code Server inside WSL (wsl2)
[2024-02-12 09:11:20.364] Windows build: 22631. Multi distro support: available. WSL path support: enabled
[2024-02-12 09:11:20.364] Scriptless setup: false
[2024-02-12 09:11:20.365] No shell environment set or found for current distro.
[2024-02-12 09:11:21.395] WSL daemon log file: 
[2024-02-12 09:11:21.399] Probing if server is already installed: if [ -d ~/.vscode-server/bin/31c37ee8f63491495ac49e43b8544550fbae4533 ]; then printf 'install-found '; fi; if [ -f /etc/alpine-release ]; then printf alpine-; fi; uname -m
[2024-02-12 09:11:21.400] NodeExecServer run: C:\Windows\System32\wsl.exe -d Ubuntu-22.04 -e sh -c if [ -d ~/.vscode-server/bin/31c37ee8f63491495ac49e43b8544550fbae4533 ]; then printf 'install-found '; fi; if [ -f /etc/alpine-release ]; then printf alpine-; fi; uname -m
[2024-02-12 09:11:21.840] Probing result: x86_64
[2024-02-12 09:11:21.841] No server install found in WSL, needs linux-x64
[2024-02-12 09:11:21.841] Getting server from client side
[2024-02-12 09:11:21.842] Downloading VS Code Server stable - 31c37ee8f63491495ac49e43b8544550fbae4533 into C:\Users\CY21_CB\AppData\Local\Temp\vscode-remote-wsl\stable\31c37ee8f63491495ac49e43b8544550fbae4533\vscode-server-stable-linux-x64.tar.gz.
[2024-02-12 09:11:22.058] Download checksum: 3e3826dee600ad4251518f141f04e82cc939f8f3b03ec4ee8d17b6d0428906c3
[2024-02-12 09:11:24.086] Unable to download server on client side: Error: Request downloadRequest failed with message: aborted. Will try to download on WSL side.
[2024-02-12 09:11:24.087] NodeExecServer run: C:\Windows\System32\wsl.exe -d Ubuntu-22.04 sh -c '"$VSCODE_WSL_EXT_LOCATION/scripts/wslServer.sh" 31c37ee8f63491495ac49e43b8544550fbae4533 stable code-server .vscode-server --host=127.0.0.1 --port=0 --connection-token=2790098295-2179853997-2796801725-3650435777 --use-host-proxy --without-browser-env-var --disable-websocket-compression --accept-server-license-terms --telemetry-level=all'
[2024-02-12 09:11:24.720] Setting up server environment: Looking for ~/.vscode-server/server-env-setup. Not found.
[2024-02-12 09:11:24.720] WSL version: 5.15.133.1-microsoft-standard-WSL2 Ubuntu-22.04
[2024-02-12 09:11:24.720] Updating VS Code Server to version 31c37ee8f63491495ac49e43b8544550fbae4533
[2024-02-12 09:11:24.720] Removing previous installation...
[2024-02-12 09:11:24.720] Installing VS Code Server for x64 (31c37ee8f63491495ac49e43b8544550fbae4533)
[2024-02-12 09:11:24.720] Downloading:      ........
[2024-02-12 09:11:28.632] gzip: stdin: unexpected end of file
[2024-02-12 09:11:28.632] tar: Unexpected EOF in archive
[2024-02-12 09:11:28.632] tar: Error is not recoverable: exiting now
[2024-02-12 09:11:28.632] 
[2024-02-12 09:11:28.632] tar is unable to read ~/.vscode-server/bin/31c37ee8f63491495ac49e43b8544550fbae4533-1707683903.tar.gz. Either the file is corrupt or tar has an issue.
[2024-02-12 09:11:28.632] There's a known WSL issue with tar on Ubuntu 19.10.
[2024-02-12 09:11:28.632] See workaround in https://github.com/microsoft/vscode-remote-release/issues/1856.
[2024-02-12 09:11:28.632] Reload the window to initiate a new server download.
[2024-02-12 09:11:28.632] For help with startup problems, go to https://code.visualstudio.com/docs/remote/troubleshooting#_wsl-tips
[2024-02-12 09:15:36.050] Download in background is enabled

Into WSL distro here Ubuntu 22.04, I can see that the archive is corrupted

$ file ~/.vscode-server/bin/31c37ee8f63491495ac49e43b8544550fbae4533-1707
683903.tar.gz
~/.vscode-server/bin/31c37ee8f63491495ac49e43b8544550fbae4533-1707683903.tar.gz: gzip compressed data, from Unix, original size modulo 2^32 3390848081

$ tar tf ~/.vscode-server/bin/31c37ee8f63491495ac49e43b8544550fbae4533-1707683903.tar.gz
vscode-server-linux-x64/
vscode-server-linux-x64/package.json
vscode-server-linux-x64/out/
vscode-server-linux-x64/out/bootstrap-fork.js
vscode-server-linux-x64/out/nls.metadata.json
vscode-server-linux-x64/out/server-cli.js
vscode-server-linux-x64/out/bootstrap-node.js
vscode-server-linux-x64/out/bootstrap-amd.js
vscode-server-linux-x64/out/bootstrap.js
vscode-server-linux-x64/out/vs/
vscode-server-linux-x64/out/vs/base/
...
vscode-server-linux-x64/node
gzip: stdin: unexpected end of file
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now

So I tried to install vscode directly into WSL using official documentation: https://github.com/coder/code-server

$ curl -fsSL https://code-server.dev/install.sh | sh
...
$ type code-server
code-server is /usr/local/bin/code-server

We can see that the tool is installed and functional, but as VScode (windows side) do not search code-server in $PATH but into ~/.vscode-server/bin/31c37ee8f63491495ac49e43b8544550fbae4533-1707683903 it continue to download the corrupted archive file

Indeed into VSCode log we can see the line Probing if server is already installed: if [ -d ~/.vscode-server/bin/31c37ee8f63491495ac49e43b8544550fbae4533 ]; then printf 'install-found '; fi

jmservier commented 7 months ago

I tried also to install code-server into the directory expected by VSCode, as below, but it seems that some parameters is not used or new

WSL side

$ mkdir ~/.vscode-server/bin/31c37ee8f63491495ac49e43b8544550fbae4533
$ curl -Lo/tmp/code-server-4.21.1.tar.gz https://github.com/coder/code-server/releases/download/v4.21.1/code-server-4.21.1-linux-amd64.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 87.8M  100 87.8M    0     0  31.3M      0  0:00:02  0:00:02 --:--:-- 42.3M
$ tar xf /tmp/code-server-4.21.1.tar.gz -C ~/.vscode-server/bin/31c37ee8f63491495ac49e43b8544550fbae4533/ --strip-components=1

Windows Side through VScode when clicking on connect to:

...
[2024-02-12 09:56:02.550] Starting server:  ~/.vscode-server/bin/31c37ee8f63491495ac49e43b8544550fbae4533/bin/code-server --host=127.0.0.1 --port=0 --connection-token=1347923089-2537403701-3775612449-1797309535 --use-host-proxy --without-browser-env-var --disable-websocket-compression --accept-server-license-terms --telemetry-level=all
[2024-02-12 09:56:02.896] [2024-02-11T21:26:45.491Z] error Unknown option --connection-token=1347923089-2537403701-3775612449-1797309535
ijaouani commented 7 months ago

I was reproducing 2 min ago and now it works. Temp issue ?

jmservier commented 7 months ago

I still have the issue. As workaround I solved like this:

  1. VSCode side: trigger action connect to Distro the install scripts is launched and failed as described
  2. WSL side: extract the archive and do not bother about the error
    
    $ tar xf  ~/.vscode-server/bin/31c37ee8f63491495ac49e43b8544550fbae4533-1707687953.tar.gz

gzip: stdin: unexpected end of file tar: Unexpected EOF in archive tar: Unexpected EOF in archive tar: Error is not recoverable: exiting now

3. check that the archive is extracted

$ [[ -d vscode-server-linux-x64 ]] && echo 'Succesfully extracted' || echo 'Error extraction failed' >2

4. move and rename the `vscode-server-linux-x64` directory at expected location

mv vscode-server-linux-x64/ ~/.vscode-server/bin/31c37ee8f63491495ac49e43b8544550fbae4533


5. Now connection will works from VSCode side
beejjacobs commented 2 months ago

I had a similar issue along the lines of ~/.vscode-server/bin/<version>/code-server not found. I ended up deleting ~/.vscode-server/bin, and next time I tried to connect to WSL from vscode, it downloaded vscode-server again and worked.