Oh No! Problem with MergeList /var/lib/apt/lists!
So you’re using Ubuntu 11.04 or something and the updater has a big “red bar” badge. You click on it and you get “Could not initialize package information” and a whole bunch of stuff that makes sense to people who are smarter then me. Some thing about problems with a merglist and possible other complaints about what you had for dinner and the quality of your breath.
I’ve had this problem crop up twice since I’ve installed 11.04. I am not totally positive, but it MIGHT be because I did an upgrade from 10 to 11 instead of a clean clear and righteous install. I didn’t want to lose my files and custom compiles (which of course I had to do anyway) of ffmpeg and various other toys and such. But since this has happened to me a couple times, maybe it’s happened to others. So I am documenting what I found here for future cultures and it’s easier to keep track then flashcards.
So you drop into terminal and do something like:
sudo apt-get clean
sudo apt-get update
sudo apt-get upgrade
or if you’re feeling swarmy like me:
sudo apt-get clean && sudo apt-get update && sudo apt-get upgrade
BOOM! no joy… the following errors come up (or similar)
Reading package lists… Error!
E: Encountered a section with no Package: header
E: Problem with MergeList /var/lib/apt/lists/us.archive.ubuntu.com_ubuntu_dists_natty_main_binary-amd64_Packages
E: The package lists or status file could not be parsed or opened.
What now sherlock? Well, after some digging (read as a 2 minute google search) I found that the package lists are stored in, you guessed it, /var/lib/apt/lists. Thing is, all the permissions are OK and everything looks good, so it must be some sort of lexicon or procedural error in the apt-get process. My attempts into figuring out what REALLY was going on were difficult. It’s fairly easy to fix though:
sudo rm -rfv /var/lib/apt/lists/*
And thats it. Doing the above apt-get update will now work. Now keep in mind, you ARE deleting some sort of critical system files. So if this in any way turns your machine into a smoldering pile of dingo offal, it’s not my fault. You might want to make a back up of these files, just in case.
sudo tar -zcvf ~/apt_list_backup.tgz /var/lib/apt/lists
That way, in case something DOES go wrong you can revert your change before you hand your machine to your niece or nephew to fix.
Easy cheesy, lemon squeezy! Hope this helped.