update-alternatives: error: /var/lib/dpkg/alternatives/vim corrupt: invalid status

12

The alternatives entries are hopelessly broken.

  1. 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.

  2. 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.

  3. Proceed analogously for vimdiff, rvim and other corrupted entries.

Share:
12

Related videos on Youtube

Thor Bjørn Rudi Thorkildsen
Author by

Thor Bjørn Rudi Thorkildsen

Updated on September 18, 2022

Comments

  • Thor Bjørn Rudi Thorkildsen
    Thor Bjørn Rudi Thorkildsen over 1 year

    How can I get all of my julian days to dates?

    enter image description here

    • David Foerster
      David Foerster over 8 years
      What's the content of /var/lib/dpkg/alternatives/vim and the output of LC_MESSAGES=C update-alternatives --query vim? Same for vimdiff, please.
    • MD-7
      MD-7 over 8 years
      @DavidFoerster I've edited the question to include the information.
    • muru
      muru over 8 years
      That file is indeed corrupted. Here's what mine looks like: paste.ubuntu.com/14264045
    • MD-7
      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
      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 after 60).
    • MD-7
      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
      muru over 8 years
      Well, 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
      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
      muru over 8 years
      I 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
      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
    MD-7 over 8 years
    This 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
    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
    MD-7 over 8 years
    PHEW! 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!