Monday, December 16, 2013

How to fix the "LANGUAGE = (unset)" perl errors on Debian

First try two commands:

$export LC_ALL=C.UTF-8
$sudo update-locale

If it does not work try:


Add two lines into /etc/environment file

$vi /etc/enviroment
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8

If it does not work try:


Posting this because I couldn't find a solution posted for a non-interactive way to fix this ...


THE PROBLEM: Perl gives LANGUAGE = unset errors.

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
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



INTERACTIVELY FIX (debian):

# dpkg-reconfigure locales
(Select your language and hit "OK")


PROGRAMTICALLY FIX (debian):

# sed -i "s/^# en_US/en_US/" /etc/locale.gen

# grep -v "^#" /etc/locale.gen
en_US ISO-8859-1
en_US.ISO-8859-15 ISO-8859-15
en_US.UTF-8 UTF-8


#localedef -v -c -i en_US -f UTF-8 en_US.UTF-8

# /usr/sbin/locale-gen
Generating locales (this might take a while)...
en_US.ISO-8859-1... done
en_US.ISO-8859-15... done
en_US.UTF-8... done
Generation complete.

# update-locale LANG=en_US.UTF-8

===========================================================================
Answering myself: 
I've managed to solve the problem by adding 

Code:
LANGUAGE = en_US.UTF-8
LC_ALL = en_US.UTF-8
LANG = en_US.UTF-8
LC_TYPE=en_US.UTF-8
to /etc/environment and rebooting.

If it does not work try:

add following to /etc/default/locate

LC_CTYPE=en_US.UTF-8
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
run sudo dpkg-reconfigure locales
select locate en_US.UTF-8 in the "Locates to be generated" tab.
select en_US.UTF-8 in the "Default locate for the system environment" tab.
run sudo reboot

No comments: