How to solve the LC_ locales issue in Debian

Does your Debian‘s based distro such as UbuntuLinux MintElementary OSLinux LitedeepinantiXZorin OSLXLEPeppermint OS and SparkyLinux,  complain about LC_* locales. Like the following complaining message.

perl: warning: Setting locale failed. 
perl: warning: Please check that your locale settings: 
 LANGUAGE = "en_US:en", 
 LC_ALL = (unset), 
 LC_MESSAGES = "en_US.UTF-8", 
 LANG = "en_US.UTF-8" 
 are supported and installed on your system. 
perl: warning: Falling back to the standard locale ("C"). 
locale: Cannot set LC_CTYPE to default locale: No such file or directory 
locale: Cannot set LC_MESSAGES to default locale: No such file or directory 
locale: Cannot set LC_ALL to default locale: No such file or directory
....

All you have to do to fix that, is adding the following to /root/.bashrc and /home/USERNAME/.bashrc:

Do not forget to replace USERNAME with your own username.

lc_fix() {
    export LANGUAGE=en_US.UTF-8
    export LANG=en_US.UTF-8
    export LC_ALL=en_US.UTF-8
    if [[ "$1" == 'gen' ]]; then
        locale-gen en_US.UTF-8
        dpkg-reconfigure locales
    fi
}
lc_fix

If your locale language is something else, just replace the ‘en_US.UTF-8‘ with the one you’d prefer.

Then restart the terminal, or just reload the bash configuration file, by:

$ . ~/.bashrc

Finally, do the following as root or by using sudo :

$ lc_fix gen

Keep in mind that:

Warning: Using LC_ALL is strongly discouraged as it overrides everything. Please use it only when testing and never set it in a startup file. source

And that’s it.. Enjoy your Debian 🙂

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.