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

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

我该怎么解决呢?


当前回答

另一个与git相关的答案:

问题的根源可能是Git服务器。如果所有这些都失败了,请尝试在服务器上执行dpkg-reconfigure区域设置(或适合您的发行版的任何设置)。

其他回答

以下是接受的答案:

LANG=C ssh hunter2。

LC_ALL=C ssh hunter2

在客户端,我成功了。

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

你没有提到具体的平台,但我可以重现你的问题:

% 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中包含

AcceptEnv LANG LC_*

它允许客户端将这些环境变量的值传播到新的会话中。

如果你不需要完整的区域设置,警告会提示你如何压制它:

% env LANG=C perl -e exit
%

或与Bash:

$ LANG=C perl -e exit
$ 

要想永久解决问题,请选择其中之一

在旧的主机上,在shell的初始化文件中设置LANG环境变量。 在客户端修改环境,例如,使用命令LANG=C ssh hunter2而不是ssh hunter2。 如果您拥有管理员权限,可以通过注释掉本地/etc/ssh/ssh_config文件中的SendEnv LANG LC_*行来阻止ssh发送环境变量。(多亏了这个回答。有关更多信息,请参阅OpenSSH中的Bug 1285。)

在Debian上,经过大量搜索,这个方法奏效了。

第一:

sudo apt-get purge locales

然后:

sudo aptitude install locales

还有著名的:

sudo dpkg-reconfigure locales

这消除了系统的区域设置,然后重新安装区域设置,并将libc6从2.19降级到2.13,这就是问题所在。然后它再次配置区域设置。

将缺失的地区添加到.bash_profile文件中:

echo "export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8">>~/.bash_profile

然后来源你的.bash_profile文件:

source ~/.bash_profile

这通常意味着您还没有正确地在Linux机器上设置区域设置。

在Debian或Ubuntu上,这意味着你需要去做

$ sudo locale-gen
$ sudo dpkg-reconfigure locales

另参见man locale-gen。