Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix a locale setting warning from Perl

Tags:

perl

locale

When I run perl, I get the warning:

perl: warning: Setting locale failed. perl: warning: Please check that your locale settings:     LANGUAGE = (unset),     LC_ALL = (unset),     LANG = "en_US.UTF-8" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C").

How do I fix it?

like image 921
xain Avatar asked Mar 23 '10 12:03

xain


People also ask

Are supported and installed on system Perl warning falling back to standard locale C?

perl: warning: Falling back to the standard locale ("C"). The problem is that your system's locale is not set. You may be missing the software entirely or just have not configured the locale. This message may appear for example when you are installing new packages into your Linux system.


2 Answers

Here is how to solve it on Mac OS X v10.7 (Lion) or Cygwin (Windows 10):

Add the following lines to your bashrc or bash_profile file on the host machine:

# Setting for the new UTF-8 terminal support in Lion export LC_CTYPE=en_US.UTF-8 export LC_ALL=en_US.UTF-8 

If you are using Z shell (zsh), edit file zshrc:

# Setting for the new UTF-8 terminal support in Lion LC_CTYPE=en_US.UTF-8 LC_ALL=en_US.UTF-8 
like image 118
Allen Bargi Avatar answered Sep 24 '22 03:09

Allen Bargi


Your OS doesn't know about en_US.UTF-8.

You didn't mention a specific platform, but I can reproduce your problem:

% uname -a OSF1 hunter2 V5.1 2650 alpha % perl -e exit perl: warning: Setting locale failed. perl: warning: Please check that your locale settings:     LC_ALL = (unset),     LANG = "en_US.UTF-8"     are supported and installed on your system. perl: warning: Falling back to the standard locale ("C").

My guess is you used ssh to connect to this older host from a newer desktop machine. It's common for /etc/ssh/sshd_config to contain

AcceptEnv LANG LC_* 

which allows clients to propagate the values of those environment variables into new sessions.

The warning gives you a hint about how to squelch it if you don't require the full-up locale:

% env LANG=C perl -e exit %

or with Bash:

$ LANG=C perl -e exit $ 

For a permanent fix, choose one of

  1. On the older host, set the LANG environment variable in your shell's initialization file.
  2. Modify your environment on the client side, e.g., rather than ssh hunter2, use the command LANG=C ssh hunter2.
  3. If you have administrator rights, stop ssh from sending the environment variables by commenting out the SendEnv LANG LC_* line in the local /etc/ssh/ssh_config file. (Thanks to this answer. See Bug 1285 for OpenSSH for more.)
like image 41
Greg Bacon Avatar answered Sep 23 '22 03:09

Greg Bacon