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

Linux howto's, compile information, information on whatever we learned on working with linux, MACOs and - of course - Products of the big evil....
Post Reply
User avatar
^rooker
Site Admin
Posts: 1481
Joined: Fri Aug 29, 2003 8:39 pm

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

Post 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
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
User avatar
^rooker
Site Admin
Posts: 1481
Joined: Fri Aug 29, 2003 8:39 pm

Make sure "LC_ALL" is also set.

Post 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...
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
Post Reply