安装vim时断电引起“E484:Can’t open file /usr/share/vim/vim82/syntax/syntax.vim”

在安装vim时遇到电脑断电,导致安装不完整并出现文件锁定。尝试重新安装、卸载及切换root模式删除vim均因文件权限问题失败。最终通过重装虚拟机解决,现在vim可以正常使用。

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

一、问题描述

在安装vim的过程中,正在安装驱动时,电脑突然没电自动关机了,插上电源之后,再打开虚拟机,启动vim,就出现了以下问题
在这里插入图片描述
显示了如上图所示的错误,但我还是按了enter,之后虽然进入了编辑器,但是再写完代码之后却出现了无法保存和退出的情况。

输入“:wq” 时提示的错误
在这里插入图片描述
输入“:q” 时提示的错误
在这里插入图片描述
最后是输入了“:q!” 强制退出vim。

二、尝试的解决办法

在网上找了很多办法尝试着解决这个问题,发现这是由于在上一次下载的过程中,由于电脑突然断电的原因导致下载安装失败,使得内部资源被锁住,使得vim程序不可用。

以下是我尝试过的一些方法。

1、重新安装vim
键盘Ctrl+Alt+T进入终端,输入指令“sudo apt-get install vim”,但是出现了以下问题
在这里插入图片描述
提示无法使用“/var/lib/dpkg/lock-frontend”、"/var/lib/dpkg/lock"和“/var/cache/apt/archive/ lock”,导致下载失败。

2、卸载vim,再重新安装
键盘Ctrl+Alt+T进入终端,输入卸载指令“sudo apt-get remove vim vim-runtime vim-tiny vim-common vim-scripts vim-doc”,但是出现了与输入相同的错误,提示以上文件为仅读文件,导致无法进行删除。

切换尝试切换到root模式进行删除,输入“sudo su -”进入root模式,(退出的快捷键为Ctrl+D),在root模式下输入以下指令
sudo rm /var/cache/apt/archive/ lock
sudo rm /var/lib/dpkg/lock
sudo rm /var/lib/dpkg/lock-frontend

大多数人到这步就可以删除vim,再重新安装了,但是我仍然提示该文件为仅读文件(TAT),于是按照上面的三个路径来寻找文件时,又提示这几个文件不存在
在这里插入图片描述
于是又尝试着再安装一次vim,但还是以失败告终。

最后万不得已,使出了重装大法,把虚拟机卸载了又重新安装了一次,重新安装之后就可以正常使用了。

三、结语

以上就是我在安装vim过程中遇到的问题,以及尝试过的一些办法,网上还有很多大神的方法我都还没试过,因为到后面实在不想搞了,而且刚开始学Linux,没有什么文件,所以干脆卸了重装算了。如果大家遇到了类似问题,并且成功解决了,欢迎大家留言一起讨论!

Rebuild started: Project: Project *** Using Compiler 'V6.22', folder: 'E:\Keil_v5\ARM\ARMCLANG\Bin' Rebuild target 'Target 1' assembling startup_stm32f10x_md.s... Start/core_cm3.c(445): error: non-ASM statement in naked function is not supported 445 | uint32_t result=0; | ^ Start/core_cm3.c(442): note: attribute is here 442 | uint32_t __get_PSP(void) __attribute__( ( naked ) ); | ^ Start/core_cm3.c(465): error: parameter references not allowed in naked functions 465 | "BX lr \n\t" : : "r" (topOfProcStack) ); | ^ Start/core_cm3.c(461): note: attribute is here 461 | void __set_PSP(uint32_t topOfProcStack) __attribute__( ( naked ) ); | ^ Start/core_cm3.c(479): error: non-ASM statement in naked function is not supported 479 | uint32_t result=0; | ^ Start/core_cm3.c(476): note: attribute is here 476 | uint32_t __get_MSP(void) __attribute__( ( naked ) ); | ^ Start/core_cm3.c(499): error: parameter references not allowed in naked functions 499 | "BX lr \n\t" : : "r" (topOfMainStack) ); | ^ Start/core_cm3.c(495): note: attribute is here 495 | void __set_MSP(uint32_t topOfMainStack) __attribute__( ( naked ) ); | ^ 4 errors generated. compiling core_cm3.c... compiling misc.c... compiling system_stm32f10x.c... compiling stm32f10x_adc.c... compiling stm32f10x_dac.c... compiling stm32f10x_exti.c... compiling stm32f10x_dbgmcu.c... compiling stm32f10x_dma.c... compiling stm32f10x_crc.c... compiling stm32f10x_cec.c... compiling stm32f10x_bkp.c... compiling stm32f10x_can.c... compiling stm32f10x_flash.c... compiling stm32f10x_pwr.c... compiling stm32f10x_fsmc.c... compiling stm32f10x_
03-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值