update-alternatives: error: /var/lib/dpkg/alternatives/vim corrupt: invalid status
12
The alternatives entries are hopelessly broken.
You should remove them with:
sudo update-alternatives --remove-all vim sudo rm -f /etc/alternatives/vim /var/lib/dpkg/alternatives/vim
If
update-alternatives
complains about corrupt files again, ignore it and just proceed to delete them with the next command.Then re-install their packages with:
sudo apt-get install --reinstall vim
This will restore the alternatives entries according to the packages available on your system.
Proceed analogously for
vimdiff
,rvim
and other corrupted entries.
Related videos on Youtube
Author by
Thor Bjørn Rudi Thorkildsen
Updated on September 18, 2022Comments
-
Thor Bjørn Rudi Thorkildsen over 1 year
-
David Foerster over 8 yearsWhat's the content of
/var/lib/dpkg/alternatives/vim
and the output ofLC_MESSAGES=C update-alternatives --query vim
? Same forvimdiff
, please. -
MD-7 over 8 years@DavidFoerster I've edited the question to include the information.
-
muru over 8 yearsThat file is indeed corrupted. Here's what mine looks like: paste.ubuntu.com/14264045
-
MD-7 over 8 years@muru Ick, thats not right at all, haha! Yeah, it raised a red flag as soon as I saw the output. Thanks for the comparison. I just copied in the contents of your file into mine. New errors:
/var/lib/dpkg/alternatives/vimdiff corrupt: unexpected end of file while trying to read master file
/var/lib/dpkg/alternatives/rvim corrupt: line not terminated while trying to read status
-
muru over 8 years@MD-7 I'm not sure copying mine was the best idea - you don't have
vim.gnome
, for one. For another, the paste doesn't show it, but the file has an extra, blank line at the end (one more line after60
). -
MD-7 over 8 years@muru True. It was worth a shot, at least. But its beginning to look there's a lot of files that are corrupted. Surely there's some way to nuke vim off my system. It seems counter-intuitive that the system wouldn't let you remove a corrupted program.
-
muru over 8 yearsWell, it's not Vim that's corrupted, it's the package manager's information of vim packages. :P Anyway, if you look at my file and the output of
-update-alternatives
, you might see a pattern. (And remember the extra blank line at the end.) -
MD-7 over 8 years@muru Ahh, right, right, thanks. That file's fixed. But do I really have to just keep going in and manually fixing all these files? File x is corrupted > search on internet for a sample of that file > extrapolate a proper file for my sytem; File y is corrupted > search on internet for a sample of that file > extrapolate a proper file for my sytem >>... Is this really the solution?
-
muru over 8 yearsI don't know about that. This is the first time I'm seeing such a corruption. When the problem gets rare enough, it's likely there are no built-in mechanisms to help. You could file a bug report, and perhaps devs could help you find what caused this.
-
MD-7 over 8 years@muru UGH. Double ick. Alright, at least I have enough information to go from here. Thanks for your help!
-
-
MD-7 over 8 yearsThis sounds promising. It's worked for the first couple files. But now I run
sudo update-alternatives --remove-all rvim
and I get this error message:update-alternatives: error: /var/lib/dpkg/alternatives/rvim corrupt: line not terminated while trying to read status
. It sounds like it hates the file format (It is corrupted, crazy characters everywhere). Am I back to finding example files online? -
David Foerster over 8 years“If
update-alternatives
complains about corrupt files again, ignore it and just proceed to delete them with the next command.” -
MD-7 over 8 yearsPHEW!
rvim
was the last one. That could have been a lot worse. Sorry for skipping over that bit that you had to quote for me haha. Purged then reinstalled. Problem solved. Many thanks!