VSIX 在vscode中无法安装成功

背景

今天遇到一个VSIX VS插件无法安装成功的问题,折腾许久,最后轻易解决。做个记录,以便后面能够找到,同时也方便有类似问题的技术同僚能够提高解决问题的效率。

1. 问题现象描述

开发完插件 用vsce package 打包插件为 VSIX文件

打开Extenstions (ctrl+shift+x), 并点击 所在页右上角的(点点点)...  通过本地安装VSIX...如下图(黄色标注选项):

然后选择本地的VSIX文件 进行安装, 结果VSCode 弹出窗口提示错误,错误信息如下:

ENOENT: no such file or directory, mkdir '/home/liang/.vscode-server/extensions/.024e7c03-c1fe-4063-b3b2-902c42d8d841'

2. 问题分析

根据错误提示进行了如下方式的尝试:

0x1. 查看目录是否存在

ls -la ~/.vscode-server/  

结果没有问题,所有文件在当前用户状态下均可读写

0x2. 查看目录权限是否有问题

 没问题,读写权限都有

0x3.重新安装

 仍然失败

0x4. 重新安装vscode

    没有尝试此方法(觉得麻烦花时间),但是卸载了老版本插件,重新安装老版本插件,能够成功

0x5.尝试老版本vsix安装

卸载老版本vsix,然后安装老版本vsix,结果成功后,然后再安装当前最新版本,结果失败,错误代码发生了变化:

Unknown system error -122: Unknown system error -122, close

注意:安装新版本的插件按,无需卸载原来老版本的插件,直接安装即可

0x6.其他方法(清除缓冲,重新安装npm等)

         npm cache clean -force 

         npm install -g npm

         npm install -g npm@latest

3.问题解决(磁盘空间占满导致)
0x1 磁盘空间检查

折腾许久一直没有解决,第二天突然感觉是否是磁盘空间问题,df一下,发现占有84%硬盘空间并没有占满,但是也够多。 基于错误提示:

Unknown system error -122: Unknown system error -122, close。

0x2 借助大模型Copilot

问了copilot,给出如下提示和建议:

The error Unknown system error -122: Unknown system error -122, close is a low-level system error that's usually related to the file system or the operating system itself. It's not specific to Visual Studio Code or the extension you're trying to install.

Here are a few things you can try:

0x2.1 Check the disk space: Make sure you have enough disk space on your machine. You can check this by running the command df -h.

0x2.2 Check the file system: The error might be due to a file system issue. You can check and repair the file system using the fsck command. Please note that you should unmount the file system or boot into a recovery mode before running fsck.

0x2.3 Reboot your machine: Sometimes, a simple reboot can fix system errors. If you haven't already, try rebooting your machine.

0x2.4 Check the .vsix file: Make sure the .vsix file you're trying to install is not corrupted. You can try downloading it again or installing it on a different machine to check.

根据错这些提示,特别是提示这个错误是low level,基本断定是系统的,和插件文件关系不大。检查了home目录下的文件,发现有大量临时文件,删除临时文件,释放磁盘空间。删除后再尝试安装,结果安装成功了

4. 总结

0x1.   解决问题不要盲目

其实错误提示已经比较明确了,只是没有考虑这么简单的情况,开始的尝试完全凭个人经验和网络搜索建议,十分盲目。

0x2.   解决问题的时候一定要重视注意问题的现象

第二个错误提示,更加明显,和插件文件毫无关系。安装失败只是安装过程有问题,和插件的使用没有关系,所以一开始的解决思路是错的,所以针对问题,确定错误的提示指向的范围很重要。这个问题,和插件本身没有关系。所以一开始的方法基本注定就是徒劳。

0x3. 借助AI工具

另外借助AI大模型工具,能够获得更多直接和间接的帮助。通常在走头无路的时候,能有奇效。因为我们经常陷入问题的死胡同,但是大模型的发散思维比我们强太多,哈哈.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值