Ubuntu 22.04LTS 使用code.打不开vscode(vscode内Remote-WSL连不上Ubuntu22)已解决(usr/bin/gzip: 1: ELF: not found/us

 Ubuntu 22.04LTS 使用code.打不开vscode(vscode内Remote-WSL连不上Ubuntu22)已解决(usr/bin/gzip: 1: ELF: not found/us_第1张图片

 Ubuntu 22.04LTS 使用code.打不开vscode(vscode内Remote-WSL连不上Ubuntu22)已解决(usr/bin/gzip: 1: ELF: not found/us_第2张图片

具体报错如下:

Installing VS Code Server for x64 (c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5)
Downloading: 100%
/usr/bin/gzip: 1: ELF: not found
/usr/bin/gzip: 3: : not found
/usr/bin/gzip: 4: Syntax error: "(" unexpected
tar: Child returned status 2
tar: Error is not recoverable: exiting now

tar is unable to read /home/rwlinux/.vscode-server/bin/c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5-1653063762.tar.gz. Either the file is corrupt or tar has an issue.

rwlinux@LAPTOP-8TPVIUOD:~$ code .
Installing VS Code Server for x64 (c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5)
Downloading: 100%
/usr/bin/gzip: 1: ELF: not found
/usr/bin/gzip: 3: : not found
/usr/bin/gzip: 4: Syntax error: "(" unexpected
tar: Child returned status 2
tar: Error is not recoverable: exiting now
tar is unable to read /home/rwlinux/.vscode-server/bin/c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5-1653063762.tar.gz. Either the file is corrupt or tar has an issue.
There's a known WSL issue with tar on Ubuntu 19.10.
See workaround in https://github.com/microsoft/vscode-remote-release/issues/1856.
Reload the window to initiate a new server download.

Ubuntu 22.04LTS 使用code.打不开vscode(vscode内Remote-WSL连不上Ubuntu22)已解决(usr/bin/gzip: 1: ELF: not found/us_第3张图片

原因分析:

Ubuntu22默认用的是wsl2,而之前用的是wsl1

解决办法1如下:

直接在Ubuntu里输入

echo -en '\x10' | sudo dd of=/usr/bin/gzip count=1 bs=1 conv=notrunc seek=$((0x189))

再试试code .打开vscode

如果不行再继续执行下面的步骤!!!!

解决办法2如下:

Step1:用管理员身份打开power shell输入下面指令,发现确实是wsl1的这个问题

wsl -l -v

Step2:转换

先下载下面这个链接,然后点击执行

​​​​​​https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi

然后再powershell里面输入

wsl --set-version Ubuntu-22.04 2

Step3:确保开启虚拟机

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Step3:输入

wsl --set-default-version 2

Step4:确认

wsl -l -v

完整过程:

Ubuntu 22.04LTS 使用code.打不开vscode(vscode内Remote-WSL连不上Ubuntu22)已解决(usr/bin/gzip: 1: ELF: not found/us_第4张图片

转载请申明出处(CSDN小米米小life)

你可能感兴趣的:(ubuntu,linux,运维)