Page 1 of 1

"Can't set locale; make sure $LC_* and $LANG are correct!"

Posted: Sat Dec 23, 2017 7:56 pm
by ^rooker
[PROBLEM]

On Debian Jessie (8.6), whenever I want to install any new package (using "apt-get"), I get the following warning about my locale settings obviously being quirky. :?
Can't set locale; make sure $LC_* and $LANG are correct!
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US:en",
LC_ALL = (unset),
LC_TIME = "de_AT.UTF-8",
LC_MONETARY = "de_AT.UTF-8",
LC_ADDRESS = "de_AT.UTF-8",
LC_TELEPHONE = "de_AT.UTF-8",
LC_NAME = "de_AT.UTF-8",
LC_MEASUREMENT = "de_AT.UTF-8",
LC_IDENTIFICATION = "de_AT.UTF-8",
LC_NUMERIC = "de_AT.UTF-8",
LC_PAPER = "de_AT.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
locale: Cannot set LC_ALL to default locale: No such file or directory
I've checked the current values of the related envvars:

Code: Select all

$ env | grep 'LC\|LANG' | sort
Output is:
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_ADDRESS=de_AT.UTF-8
LC_IDENTIFICATION=de_AT.UTF-8
LC_MEASUREMENT=de_AT.UTF-8
LC_MONETARY=de_AT.UTF-8
LC_NAME=de_AT.UTF-8
LC_NUMERIC=de_AT.UTF-8
LC_PAPER=de_AT.UTF-8
LC_TELEPHONE=de_AT.UTF-8
LC_TIME=de_AT.UTF-8


[SOLUTION]
In fact, after checking "/etc/locale.gen", I realized that I didn't have "de_AT.UTF-8" installed.
Run the following and check every locale that you're going to use:
$ dpkg-reconfigure locales
After hitting "<Ok>", the locales will be (re-)generated and then everything's back to normal 8) :D

Make sure "LC_ALL" is also set.

Posted: Thu Apr 19, 2018 3:11 pm
by ^rooker
It seems that "$LC_ALL" is not set by default on Xubuntu Xenial (16.04.3 LTS)... :?
There's probably a reason, but I don't know it (yet).

If the above steps for regenerating the locales don't fix the issue on your setup, add the following line to "/etc/environment":
LC_ALL="en_GB.UTF-8"
...and replace "en_GB.UTF-8" with your default locale.

NOTE: This sets LC_ALL for all users to the same default value!
If you have different users with different locales, you need to do it differently. But that's another story...