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

博客内容讲述了在Ubuntu 22.04上使用WSL2时,遇到VSCode服务器安装失败的错误,该错误涉及gzip和tar的故障。提供了两种解决方案:一是通过在Ubuntu终端执行特定命令修复gzip;二是通过升级WSL版本到2,并启用虚拟机平台。解决方案详细且包括了每一步的操作指令。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

 

具体报错如下:

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)

评论 20
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值