当我运行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").

我该怎么解决呢?


当前回答

对于Ubuntu Server和Debian:

不需要在bashrc中创建导出或处理dpkg-reconfigure。

只需将/etc/default/locale的内容替换为:

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

其他回答

在我的情况下,使用Debian 8.6 (Jessie),我必须更改设置:

/etc/ssh/ssh_config` for `#AcceptEnv LANG LC_*

and

sshd_config为SendEnv LANG LC_*

然后重新启动ssh服务。

最后,我做到了:

locale-gen en_US。UTF-8和dpkg-reconfigure区域设置

向~/添加正确的区域设置。bashrc,(~ /。Bash_profile, /etc/environment之类的文件可以解决这个问题,但是不建议这样做,因为它会覆盖/etc/default/locale的设置,这在最好的情况下是令人困惑的,在最坏的情况下可能会导致区域设置不一致。

相反,应该直接编辑/etc/default/locale,它可能看起来像这样:

LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE=en_US

更改将在下次登录时生效。你可以通过/etc/default/locale在现有的shell中获取新的语言环境,就像这样:

$ . /etc/default/locale
sudo nano /etc/locale.gen

取消注释你想要使用的地区(例如en_US。utf - 8 utf - 8):

然后运行:

sudo /usr/sbin/locale-gen

来源:配置区域设置

您需要在/etc/default/locale中适当地配置语言环境、注销、登录,然后运行常规命令

root@host:~# echo -e 'LANG=en_US.UTF-8\nLC_ALL=en_US.UTF-8' > /etc/default/locale
root@host:~# exit
local-user@local:~$ ssh root@host
root@host:~# locale-gen en_US.UTF-8
root@host:~# dpkg-reconfigure locales

Use:

export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_CTYPE=en_US.UTF-8

它适用于Debian。我不知道为什么,但是locale-gen没有结果。

重要!这是暂时的解决办法。它必须在每个会话中运行。