How To Fix “pacman: error while loading shared libraries” Error In Arch Linux
For the past few days, I have been extensively testing PIP and Pipenv tools in my Arch Linux system. While testing these tools, I had to reinstall and downgrade Python2.x, Python 3.x packages and some other Python dependencies package many times. At some point, It broke my Arch Linux and pacman stopped working. Whenever I run pacman, I got an error that says “pacman: error while loading shared libraries: libidn2.so.0: cannot open shared object file: No such file or directory”.
Not just pacman, some other applications, such as pacaur, yaourt, packer, virtualbox and transmission etc., also stopped working. When I try to open any one of these applications, I keep getting this message – “error while loading shared libraries: libidn2.so.0: cannot open shared object file”. I may have uninstall something that I couldn’t remember.
To my bad luck, It was my personal system and I don’t want to reinstall it since it has a lot of applications. So, reinstalling OS and all applications might took two or may be more days. After vigorously searching on Arch Linux wiki and other Linux forums like a mad man, I finally managed to fixed it. If you ever run into a problem something like this, look nowhere, just download the source file and copy the missing file(s) to /usr/lib/ folder. As far as I searched on the web, this method seems very easiest one so far. Read on to know how I fixed this error.
Fix “pacman: error while loading shared libraries” Error In Arch Linux
As I said already, I kept getting this error – “pacman: error while loading shared libraries: libidn2.so.0: cannot open shared object file: No such file or directory” when I run pacman command or any AUR helpers such as pacaur, packare, yaourt and I even can’t open VirtualBox application and Transmission client.
So, the actual problem here is the file “libidn2.so.0” is gone missing. We need to find it out!
ls -la /usr/lib/libidn*
Sample output from my Arch Linux system:
lrwxrwxrwx 1 root root 22 Jul 22 2013 /usr/lib/libidnkitlite.so -> libidnkitlite.so.1.0.2 lrwxrwxrwx 1 root root 22 Jul 22 2013 /usr/lib/libidnkitlite.so.1 -> libidnkitlite.so.1.0.2 -rw-r--r-- 1 root root 276352 Jul 22 2013 /usr/lib/libidnkitlite.so.1.0.2 lrwxrwxrwx 1 root root 18 Jul 22 2013 /usr/lib/libidnkit.so -> libidnkit.so.1.0.2 lrwxrwxrwx 1 root root 18 Jul 22 2013 /usr/lib/libidnkit.so.1 -> libidnkit.so.1.0.2 -rw-r--r-- 1 root root 282368 Jul 22 2013 /usr/lib/libidnkit.so.1.0.2 lrwxrwxrwx 1 root root 17 Aug 15 19:00 /usr/lib/libidn.so -> libidn.so.11.6.16 lrwxrwxrwx 1 root root 17 Aug 15 19:00 /usr/lib/libidn.so.11 -> libidn.so.11.6.16 -rwxr-xr-x 1 root root 210872 Aug 15 19:00 /usr/lib/libidn.so.11.6.16
I had “libidn.so”, but can’t find “libidn2.so.0”. Since pacman and any other package manager didn’t work, there is no way to install, upgrade or downgrade any packages from official repository or local cache. So, I thought that the only way might be to download the package that has the missing file from Internet, extract it and finally copy the missing file(s) to /usr/lib/ directory.
Let me create a directory to save libdin2 tar file:
Find and download the latest version of this package. A quick google search brought me here.
Extract the file:
tar xf libidn2-2.0.4-2-x86_64.pkg.tar.xz
The above command extracted the contents of the file in a directory named “usr”.
Go to the usr/lib folder: (Note – It is usr/lib not /usr/lib)
Finally copy the missing file, in our case it is libidn2.so.0, to /usr/lib/ directory of your Arch Linux system.
cp libidn2.so.0 /usr/lib/
Then, I ran:
sudo pacman -syu
Voila! Pacman works now!!
Oops! Oh no, wait.. It didn’t work. I got this error after few minutes.
[....] (511/511) checking keys in keyring [######################] 100% (511/511) checking package integrity [######################] 100% (511/511) loading package files [######################] 100% (511/511) checking for file conflicts [######################] 100% error: failed to commit transaction (conflicting files) libidn2: /usr/lib/libidn2.so.0 exists in filesystem Errors occurred, no packages were upgraded.
To fix this, I ran:
sudo pacman -S libidn2 --force
Then, I tried update again:
sudo pacman -Syu
Fixed!! All good now.
So, if you guys ever run into an issue something like “error while loading shared libraries: .. cannot open shared object file: No such file or directory”, one way to fix this is to find the the package that contains the missing files, download the latest version of the package, extract it and copy the missing files to /usr/lib/ directory. Of course, there could be many ways to fix such kind of issues. But this is the only working solution I could find and I find this much easier and faster. This trick might work on other Linux distros too.
And, that’s all for now. I will be soon here with another useful guide. Until then, stay tuned with OSTechNix!
Thanks for stopping by!
Help us to help you:
- Subscribe to our Email Newsletter : Sign Up Now
- Support OSTechNix : Donate Via PayPal
- Download free E-Books and Videos : OSTechNix on TradePub
- Connect with us: Facebook | Twitter | Google Plus | LinkedIn | RSS feeds
Have a Good day!!