Fixing “No such file or directory” locale errors
Tags: Debian, linux, locale, locales, ubuntu
While working on a new ubuntu karmic system I ran across the following locale error when attempting to perform a dist-upgrade. I was able to reproduce it by running ‘dpkg-reconfigure locales’ thinking that this might fix the error, sadly it did not.
Here’s the error I was seeing:
root@harrowdown:~# dpkg-reconfigure locales perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LANG = "en_US" 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
If you boil the error message down a bit the problem becomes a bit more clear. It’s trying to say that the “en_US” locale could not be found:
perl: warning: Setting locale failed. LANG = "en_US"
To install the missing “en_US” locale run ‘locale-gen en_US’ which should yeild the following output.
root@harrowdown:~# locale-gen en_US Generating locales... en_US.ISO-8859-1... done Generation complete.
And as you can see the errors are no longer printed when I call dpkg-reconfigure (or anything else for that matter).
root@harrowdown:~# dpkg-reconfigure locales Generating locales... en_AG.UTF-8... done en_AU.UTF-8... done en_BW.UTF-8... done en_CA.UTF-8... done en_DK.UTF-8... done en_GB.UTF-8... done en_HK.UTF-8... done en_IE.UTF-8... done en_IN.UTF-8... done en_NG.UTF-8... done en_NZ.UTF-8... done en_PH.UTF-8... done en_SG.UTF-8... done en_US.ISO-8859-1... up-to-date en_US.UTF-8... up-to-date en_ZA.UTF-8... done en_ZW.UTF-8... done Generation complete.
[ad]
January 21st, 2012 at 8:22 am
Thanks,
It worked for me
[Reply]
March 13th, 2012 at 4:25 am
It didn’t work for me. On running “locale-gen en_US” I got the messages that your blog post suggest but running “dpkg-reconfigure locales” again gave the same errors:
root@server:~# dpkg-reconfigure locales
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = “en_IN”
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
Generating locales…
en_US.ISO-8859-1… up-to-date
Generation complete.
[Reply]
March 20th, 2012 at 11:32 am
Mohsin,
Try running an:
export LANGUAGE=’en_US’
Worked for me
[Reply]