Solution for “perl: warning: Setting locale failed”

September 6, 2012

Sometimes I come across Debian or Ubuntu Systems which report following error e.g. during installing new packages:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_PAPER = "de_AT.UTF-8",
LC_ADDRESS = "de_AT.UTF-8",
LC_MONETARY = "de_AT.UTF-8",
LC_NUMERIC = "de_AT.UTF-8",
LC_TELEPHONE = "de_AT.UTF-8",
LC_MEASUREMENT = "de_AT.UTF-8",
LC_TIME = "de_AT.UTF-8",
LC_NAME = "de_AT.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_ALL to default locale: No such file or directory

In this special case it is complaining about de_AT.UTF-8, as the system is setup with German / Austria. To solve this you need to do following:

# locale-gen en_US en_US.UTF-8 de_AT.UTF-8
Generating locales...
de_AT.UTF-8... done
en_US.ISO-8859-1... done
en_US.UTF-8... up-to-date
Generation complete.

Important: Replace de_AT.UTF-8 with the language it is complaining about. If you just copy’n’past it will not work, if you’re not from Austria. ;-)

After this call:

# dpkg-reconfigure locales
Generating locales...
de_AT.UTF-8... up-to-date
en_US.ISO-8859-1... up-to-date
en_US.UTF-8... up-to-date
Generation complete.

and it should work again.

11 Comments »

RSS feed for comments on this post. TrackBack URI

  1. I think this started not so long ago, after some glibc update.
    My solution:
    echo “LC_ALL=C” > /etc/default/locale

    I really don’t need this localization stuff, especially not on a server. German error messages in a console are really shitty.

    Comment by Jakob — September 17, 2012 #

  2. Thanx Jakob, this fixed my problem!!!!

    Comment by Alex — October 9, 2012 #

  3. Thanks!

    Comment by Kurt — November 1, 2012 #

  4. The “solution” of Jakob (echo “LC_ALL=C” > /etc/default/locale) made my server go down forever (even no ping).
    I had to rebuild it from an image to get it back. Did this twice to be sure it was this command, and it was..
    So be careful!

    Comment by robertu — November 8, 2012 #

  5. pour Debian:

    dans le fichier /etc/locale.gen, décommentez les locales qui vous voulez utiliser
    dans le fichier/etc/environment, vous mettez le code qui correspond à votre langue par défaut uniquement pour les deux variables LANG et LANGUAGE
    Par exemple pour le français:
    LANG=french
    LANGUAGE=fr

    Lancez sous foot
    # dpkg-reconfigure locales
    ne changez rien, validez…
    le système reconfigure automatiquement les variables à partir des fichiers de config.

    Note : Lors d’une première installation du paquet locales sous Debian, les fichiers de définition des paramètres régionaux ne sont pas générées proprement. Il suffit de reconfigurer manuellement le paquet comme indiqué ci-dessous pour que tout rentre dans l’ordre.

    lancer sous root
    # locale
    Affiche l’état de vos variables locales

    Pour les variables de type LC_* mal renseignés:
    * correspond à la dénomination de la variable (ex: TYPE, TIME, NAME, etc.)
    lancer sous root
    # export LC_*=”code du pays.code de la langue”
    Exemple pour le français
    # export LC_CTYPE=”fr_FR.UTF-8″;
    Et, c’est réglé..!

    Comment by Hugoboss972 — December 23, 2012 #

  6. Thanks a lot Robert for sharing this info! I was just going crazy searching how to get rid of this message! :D
    You saved my day and sanity!

    Comment by utout — January 11, 2013 #

  7. Thx so much! Had Anki throw “Exception(“Anki requires a UTF-8 locale.”)” and googled forever until this fixed my problem.

    Comment by thomas — January 19, 2013 #

  8. THANK YOU!!!!

    Comment by Ivan Storck — January 22, 2013 #

  9. Merci bien!!

    Comment by Samuel — August 12, 2013 #

  10. thanks!!

    Comment by lizi — July 26, 2014 #

  11. Thanks!

    Comment by Joaquin — August 6, 2014 #

Leave a comment


XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Powered by WordPress
Entries and comments feeds. Valid XHTML and CSS. 70 queries. 1.006 seconds.