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:
[email protected]:~# 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.
[email protected]:~# 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).
[email protected]:~# 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:
[email protected]:~# 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]
July 22nd, 2012 at 4:11 pm
Thank you very much!
You are the man!
[Reply]
October 7th, 2012 at 8:34 am
I had a similar problem, except that `dpkg-reconfigure locales` wasn’t enough to solve it. The locale `[email protected]` was in my environment (in the output of the `locale` command), but locales.postinst / locale-gen didn’t know it should be generated.
The solution is either to generate it:
sudo localedef -i [email protected] -f UTF-8 [email protected]
(building [email protected] from the /usr/share/i18n/locales/[email protected] locale and the /usr/share/i18n/charmaps/UTF-8.gz charmap)
Or to make sure `dpkg-reconfigure locales` will regenerate it, which is done by appending `[email protected] UTF-8` to either /var/lib/locales/supported.d/local (Ubuntu) or /etc/locale.gen (Debian).
Here is more info on serverfault: http://serverfault.com/questions/231025/fix-stubborn-setting-locale-failed#answer-237252
[Reply]
December 26th, 2012 at 9:43 am
I had similar pmbelors, to the point where I couldn’t run deluge( torrent client). It terminated with the error : locale::facet::_S_create_c_locale name not valid .I tried your export suggestion, but it was not enough. After a lot of fruitless mucking around, I examined my /etc/default/locale file & noticed that LANG was defined as en_GB.UTF-8:en so I changed that to just the UTF-8 locale. Lo! & Behold deluge is fine & no more errors. I think it may have been caused by a dodgy update script, as its only just happened today.I must also say Roll on, Gnome-Shell 3.2 for Wheezy , because right now in Wheezy we’ve got Gnome 3 sans extensions, which must be the worst of both worlds
[Reply]
January 11th, 2013 at 7:21 am
Thank you so much!!
Worked perfectly for me!
[Reply]
March 29th, 2013 at 3:24 pm
Worked for me on ubuntu server 12.04.2 64bit:
sudo locale-gen el_CY.UTF-8
Generating locales…
el_CY.UTF-8… done
Generation complete.
udo dpkg-reconfigure locales
Generating locales…
el_CY.UTF-8… up-to-date
en_AG.UTF-8… done
etc
etc
Thanks buddy 😀
[Reply]