One common problem that arises when trying to install packages on Linux is successfully installing a package, running the binary, and discovering that the package doesn’t work. What are some ways to debug this?
- Read the error message carefully
Typically when running the package command, you’ll get an error message if there’s a problem telling you which file is missing.
2. Google
Google the error message and hope that you will discover a feasible solution that you can apply. Unfortunately, the problem is likely specific with your installation and chances are 50/50 that you’ll find something useful.
3. Print shared object dependencies
Use the ldd command to print the shared object dependencies (libraries). For example, if you want to see the shared object libraries for your PHP installatioin, enter the following command:
ldd $(which php)
This will present you with a list of all the shared object libraries:
linux-vdso.so.1 (0x00007fffde2ec000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x0000705e7e869000)
libxml2.so.2 => /lib/x86_64-linux-gnu/libxml2.so.2 (0x0000705e7e01e000)
libssl.so.3 => /lib/x86_64-linux-gnu/libssl.so.3 (0x0000705e7e7bf000)
libcrypto.so.3 => /lib/x86_64-linux-gnu/libcrypto.so.3 (0x0000705e7da00000)
libpcre2-8.so.0 => /lib/x86_64-linux-gnu/libpcre2-8.so.0 (0x0000705e7df84000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x0000705e7df68000)
libsodium.so.23 => /lib/x86_64-linux-gnu/libsodium.so.23 (0x0000705e7d400000)
libargon2.so.1 => /lib/x86_64-linux-gnu/libargon2.so.1 (0x0000705e7e7b4000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x0000705e7d000000)
/lib64/ld-linux-x86-64.so.2 (0x0000705e7e95b000)
libicuuc.so.74 => /lib/x86_64-linux-gnu/libicuuc.so.74 (0x0000705e7cc00000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x0000705e7df36000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x0000705e7e7ad000)
libicudata.so.74 => /lib/x86_64-linux-gnu/libicudata.so.74 (0x0000705e7ae00000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x0000705e7aa00000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x0000705e7d9d2000)
If there are missing files, it will say “not found”, meaning that something went wrong during the installation. Figuring out how to get those missing libraries is the difficult part, but see below for more debugging tips!
4. Is the installer trying to install from two different sources?
Review the output from the ldd command carefully. Typically, the package is recompiled against new versions of the Linux OS and if no one else is complaining about the problem on Google, then it indicates that something is different about your system.
One of the possibilities is that an old version of your package is installed and the shared libraries are being sourced from two different locations, causing confusion in what shared libraries are needed. In this case, you’re in luck because you can remove the files from the other location and try reinstalling your package.
5. Are you installing from source files?
If you are installing from a zip or pulling together source files and supplying a path in your installation, it’s possible you are not building your package correctly.
6. Try a symlink to piece together missing dependencies
This is unlikely going to be the correct solution, but if the situation is dire, try creating a symlink. Shared object libraries are typically stored under /lib/x86_64-linux-gnu/, so if you see another version of the shared object library there, create a symlink to the missing file using the following command:
ln -s <<existing shared object library>> <<missing shared object library>>
7. Install on another server and compare
If all is lost, try the installation on another server. If it’s successful, compare the outputs of ldd and see what the differences are.