James John – Software Engineer

Fix “bash: warning: setlocale: LC_ALL: cannot change locale” in Debian

What is Locale?

Locales defines language and country specific setting for your programs and shell session. You can use locales to see date, time, number, currency and other values formatted as per your country or language on a Linux or Unix-like system. To set system’s locale you need use shell variable. For example, LANG variable can be used to set en_NG (English Nigeria) language.

How to Fix

What caused this is because a locale variable value set is not generated yet and they by cannot be set to the specified value, in my PC I use en_NG.UTF-8, so I ran:

$sudo locale-gen en_NG.UTF-8

Then reconfigure locale to generate and choose the language you prefer

$ sudo dpkg-reconfigure locales

Then through the listed options, select the one you wish.

 

Make sure it has been set by viewing /etc/default/locale

$ cat /etc/default/locale

 

As mine has been changed to en_NG, reboot your system to take effect.

James John

Software Engineer