perl: Warning: Setting locale failed

Asked

Viewed 9,222 times

6

There seems to be an error with the local definitions of Perl and/or the system, but the details obtained do not clarify what is happening:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_PAPER = "pt_PT.UTF-8",
    LC_ADDRESS = "pt_PT.UTF-8",
    LC_MONETARY = "pt_PT.UTF-8",
    LC_NUMERIC = "pt_PT.UTF-8",
    LC_TELEPHONE = "pt_PT.UTF-8",
    LC_IDENTIFICATION = "pt_PT.UTF-8",
    LC_MEASUREMENT = "pt_PT.UTF-8",
    LC_TIME = "pt_PT.UTF-8",
    LC_NAME = "pt_PT.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

This error is visible, for example, when making use of the command adduser:

# sudo adduser zuul

Question

How to evaluate and solve whatever this problem is with local definitions ?

x86_64
Ubuntu 12.04.4 LTS
Perl 5, version 14, Subversion 2 (v5.14.2)

3 answers

11


You can use the commando locale-gen to recompile the definition files of locality:

~$ sudo locale-gen pt_PT.UTF-8
[sudo] password for [usuário]: 
Generating locales...
  pt_PT.UTF-8... up-to-date
Generation complete.
~$

Once this is done, it will be necessary to reconfigure the locality using the commando dpkg-reconfigure:

~$ sudo dpkg-reconfigure locales
[sudo] password for [usuário]: 
Generating locales...
  en_AG.UTF-8... done
  en_AU.UTF-8... done
  ...
  pt_BR.UTF-8... done
  pt_PT.UTF-8... up-to-date
Generation complete.
~$

If you want to do it from manual way, modify the file etc/default/locale, or to a specific user, the file .pam_environment located in the folder HOME user’s.

~$ nano /etc/default/locale    # todo sistema
~$ nano $HOME/.pam_environment # usuário em específico

In older versions it is possible to use commando update-locale:

~$ sudo update-locale LANG=pt_PT.UTF-8 LC_ALL=pt_PT.UTF-8

0

The glibc language packages are probably missing. Although the variables are defined, if the binaries do not exist it is no use.

Check if language packages are available. In Fedora they are the following:

  • langpacks-en
  • glibc-langpack-pt

Once installed, excute:

$locale

LANG=pt_BR.UTF-8 LC_CTYPE="pt_BR.UTF-8" LC_NUMERIC="pt_BR.UTF-8" LC_TIME="pt_BR.UTF-8" LC_COLLATE="pt_BR.UTF-8" LC_MONETARY="pt_BR.UTF-8" LC_MESSAGES="pt_BR.UTF-8" LC_PAPER="pt_BR.UTF-8" LC_NAME="pt_BR.UTF-8" LC_ADDRESS="pt_BR.UTF-8" LC_TELEPHONE="pt_BR.UTF-8" LC_MEASUREMENT="pt_BR.UTF-8" LC_IDENTIFICATION="pt_BR.UTF-8" LC_ALL=

If your output is similar to this ok. If not, run:

$localectl set-locale LANG=pt_BR.utf8

This should solve your problems.

-1

I was having this problem on my server when logging in via ssh. What solved for me was the following: I logged into my server, inside it I opened the file /etc/environment as root and added these lines:

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.