具体报错如下:

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.

原因分析:

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

完整过程:

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

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐