本文介绍了如何修复来自 Perl 的区域设置警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行 perl 时,我收到警告:

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").

我该如何解决?

推荐答案

您的操作系统不知道 en_US.UTF-8.

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").

我的猜测是您使用 ssh 从较新的台式机连接到这台较旧的主机./etc/ssh/sshd_config 通常包含

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
%

或使用 Bash:

$ LANG=C perl -e exit
$ 

要永久修复,请选择其中之一

For a permanent fix, choose one of

  1. 在旧主机上,在 shell 的初始化文件中设置 LANG 环境变量.
  2. 在客户端修改您的环境,例如,而不是sshhunter2,使用命令LANG=C sshhunter2.
  3. 如果您具有管理员权限,请通过注释掉 local /etc/ssh/中的 SendEnv LANG LC_* 行来阻止 ssh 发送环境变量ssh_config 文件.(感谢 这个答案.有关 OpenSSH 的更多信息,请参阅 Bug 1285.)
  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.)

这篇关于如何修复来自 Perl 的区域设置警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 04:41