This is a guide for fixing apt on a ubuntu 12.04 installation, using the debian package manager dpkg, and a little common sense!
This is a story that is more out of the ordinary for the likes of the CaffiNation, Its a Linux driven how-to. I searched all night for the answer and the only response i found was re-install. UNACCEPTABLE!
I figured if someone else had what I had then hopefully this will find them. I’m not too much fo a forum dweller so this seemed like the next best thing.
I recently ungraded my home server from Ubuntu 11.10 (Oneiric Ocelot), to Ubuntu 12.04 LTS (Precise Pangolin). I thought everything went well. And it did… almost.
You should probably only continue if you care about how to fix the issue and the process I took along the way. I also promise a funny picture of an ape.Everyone likes funny pictures!
Mysql broke on the server… so the website www.puzzlepiecepro.com was down, and down with the lovely Error Establishing Database Connection!
Message staring at me. So I tried to restart Mysql, and that didn’t work, so I tried to update it…
sudo apt-get update <- to get the newest listing for the software package installer, right before I was going to do apt-get upgrade to bring all of the installed packages up to the most current version.
pzul@baldr:~$ apt-get update
only to get this wonderful and cryptic error.
apt-get: symbol lookup error: /usr/lib/i386-linux-gnu/libstdc++.so.6: undefined symbol: _ZNKSt5ctypeIwE10do_toupperEw, version GLIBCXX_3.4
OK so what the hell did that mean? Apparently though trial and error it seems that something happened during the upgrade to 12.04 and i was missing some fo the library files that run apt… and since apt is what you use to install packages well its a pain in the ass. Basically what happened is that some fo the libraries that Apt uses, and actually a lot of other things in the system too, had not installed correctly.
First check to see if Dpkg is working. This is the Debain package manager. I hadn’t had to use this package manager before so I was at a bit of a loss at first. If you type Dpkg into the prompt and it tells you it’s missing an arguement then it’s working, you just didn’t tell it what to install.
For me two libraries were missing, or one library and apt was only partially installed. I only found that out through trial and error. I reinstalled apt first, and that didn’t work.
I did this to fix the issue. wget is the command that lets you download from an external source. Unlike apt dpkg needs to have the packages on the system you are using, I think.
If you want to have a bit of explanation i hunted through http://packages.ubuntu.com/precise/ to check out what each package i was installing was before downloading it. The tree has a wonderful setup where it not only links to the downloadable packages but it also has a listing of dependencies! So if all else fails you can just download EVERY dependency for the program you are trying to make work and clean house. But that would be overkill, lets be smart about this..
- sudo su
- wget http://security.ubuntu.com/ubuntu/pool/main/a/apt/apt_0.8.16~exp12ubuntu10.2_i386.deb
- this is the command to download apt directly from the depository. a fresh copy of the broken program
- dpkg -i apt_0.8.16~exp12ubuntu10.2_i386.deb
- this command will re-install apt from the .deb file you just downloaded, it will also let you know what libraries are not the right version or missing. One by on highlight the libraries that are out of date, and re-install them
- wget http://mirror.pnl.gov/ubuntu//pool/main/g/gcc-4.6/libstdc++6_4.6.3-1ubuntu5_i386.deb
- dpkg -i libstdc++6_4.6.3-1ubuntu5_i386.deb
- The attempt to run dpkg -i apt_0.8.16~exp12ubuntu10.2_i386.deb
- then I ran apt-get update to update the index of the repositories.
- And finally apt-get upgrade to update all of the packages and dependencies to their latest version!
Now the system works like a dream and I didn’t have to re-install!
My biggest problem with Linux and the Linux community is the amount of people who think re-installing is a good option. It isn’t if you have to start from scratch for every single problem you have you won’t have a very useful computer. Yes sometimes it is easier than looking down the rabbit hole and learning a thing or two, but now after this I’m pretty sure if apt dies, or a package has a corrupt library then i can troubleshoot it.
So I’m off my soapbox, and feel a lot lot more empowered, now I know a bit more about how the server works, and I’m that much more dangerous when it comes to fixing things!
Hail to the King BABY!