Problem
While running apt-get, you run in to an error that looks like:
Can’t exec “locale”: No such file or directory at /usr/share/perl5/Debconf/Encoding.pm line 16.
Use of uninitialized value $Debconf::Encoding::charmap in scalar chomp at /usr/share/perl5/Debconf/Encoding.pm line 17.
dpkg: warning: ‘ldconfig’ not found in PATH or not executable
dpkg: error: 1 expected program not found in PATH or not executable
Note: root’s PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin
E: Sub-process /usr/bin/dpkg returned an error code (2)
This is a commonly occurring issue in Debian and Debian based Linux distributions such as Ubuntu and Linux Mint. You’ll stuck this problem and will not be able to update or install new programs.
My friend ran into this problem while running Ubuntu 12.04 but the solution presented here should be applicable to newer versions such as Ubuntu 14.04, 14.10 and 15.04 as well.
Solution
As per this old forum thread, ldconfig perhaps have been moved from libc6 to libc-bin. Here is what you can do to fix this issue.
In a terminal, use the following commands to download and extract the libc-bin package:
apt-get download libc-bin
dpkg -x libc-bin*.deb unpackdir/
Next you need to copy these files:
sudo cp unpackdir/sbin/ldconfig /sbin/
Now you need to make sure that things are in order. Run these commands to ensure that:
sudo apt-get install --reinstall libc-bin
sudo apt-get install -f
Normally, this should fix the problem of Can’t exec “locale”: No such file or directory at /usr/share/perl5/Debconf/Encoding.pm line 16. Do let me know in the comment section whether or not this fixes your problem.