Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am getting this message everytime I do something like starting or stopping a service.

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   
(Reading database ... 21173 files and directories currently installed.)  
Removing bind9 ...  
 * Stopping domain name service... bind9                                                                                [ OK ]   
Processing triggers for man-db ...   
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   

How do I fix this error ?

share|improve this question

6 Answers

up vote 22 down vote accepted

First run locale to list what locales you are supposed to have:

$ locale
LANG=C
LANGUAGE=
LC_CTYPE=fi_FI.UTF-8
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE=fi_FI.UTF-8
LC_MONETARY="C"
LC_MESSAGES=fi_FI.UTF-8
LC_PAPER="C"
LC_NAME="C"
LC_ADDRESS="C"
LC_TELEPHONE="C"
LC_MEASUREMENT="C"
LC_IDENTIFICATION="C"
LC_ALL=

The generate the missing locale and reconfigure locales to take notice:

$ sudo locale-gen fi_FI.UTF-8
Generating locales...
  fi_FI.UTF-8... done
Generation complete.

$ sudo dpkg-reconfigure locales
Generating locales...
  en_US.UTF-8... done
  fi_FI.UTF-8... up-to-date
Generation complete.

Now you will not see any errors anymore!

share|improve this answer

They should disappear after issuing:

sudo locale-gen en_US en_US.UTF-8
dpkg-reconfigure locales 

dpkg-reconfigure reconfigures packages after they have already been installed. Pass it the names of a package or packages to reconfigure. It will ask configuration questions, much like when the package was first installed.

share|improve this answer
Thanks it works :) – HackToHell Jul 11 '12 at 14:21
3  
I am glad my troubles a year ago helped you get this fixed ;) – Rinzwind Jul 11 '12 at 14:34
Shouldn't this locale be generated by default? I mean en, en_AU, en_CA, en_GB are present by default but not en_US? – Daniel Serodio Aug 15 '12 at 16:05
Ping! Your troubles are still useful. :-D – Brian Visel Sep 27 '12 at 21:35
1  
What does the dpkg-reconfigure locales command do in more detail? – Victor Nov 17 '12 at 3:38
show 3 more comments

Nothing suggested above worked in my case (Ubuntu Server 12.04LTS). What finally helped was putting to the file /etc/environment:

LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8

For some reason it was missing. The outputs for locale and other commands appeared like the variables were properly defined. In other words don't take for granted all the basic stuff is declared where it should be declared.

share|improve this answer
4  
Yes, none other worked except this one, perhaps due to updated version. But I rather prefer to put this in /etc/default/locale. – cmnajs Feb 22 at 20:18
Updated /etc/default/locale and no more warnings. Thanks – ohho Feb 26 at 7:00

Just add the following to your .bashrc file (assuming you're using bash)

export LC_ALL="en_US.UTF-8"
share|improve this answer
This sweet fix worked for me on my Amazon-EC2 image (Was running their default RHEL AMI) Thanks so much! :) – gideon Dec 1 '12 at 15:07

For Ubuntu 12.10 none of the above worked except for ratzs' solution. I recommend adding this to your /etc/bash.bashrc file:

export LC_ALL="en_ZA.UTF-8"
export LC_CTYPE="en_ZA.UTF-8"
share|improve this answer

What worked for me on 12.10 was this:

apt-get install language-pack-en-base  

This was after dpkg-reconfigure locales produced no results.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.