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

我该怎么解决呢?


当前回答

我们将设置重启后不会取消设置的区域设置。

首先打开Bash文件并编辑它:

nano .bashrc

将这些行添加到文件中:

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

通过重新加载Bash激活更改:

source ~/.bashrc

测试结果:

locale

其他回答

如果您使用Mac OS X v10.10 (Yosemite)或以上版本来连接服务器Linux,您可以尝试这些步骤。

保持/etc/ssh/sshd-config文件原始 输入~/.bash_profile 出口LANG = " en_US " 出口LC_ALL = $朗。utf - 8 运行 dpkg-reconfigure地区 并选择“en_US”。utf - 8”

以下是如何在Mac OS X v10.7 (Lion)或Cygwin (Windows 10)上解决这个问题:

在主机上的bashrc或bash_profile文件中添加以下代码行:

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

如果你使用Z shell (zsh),编辑文件zshrc:

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

我有多个用户使用不同的外壳,所以在我的情况下,这解决了:

检查哪个外壳 echo $ 0 如果bash #设置locale\nLC_CTYPE=en_US. utf -8\nLC_ALL=en_US. utf -8UTF-8" >> .bashrc 如果zsh #设置locale\nLC_CTYPE=en_US. utf -8\nLC_ALL=en_US. utf -8UTF-8" >> .zshrc

以下是接受的答案:

LANG=C ssh hunter2。

LC_ALL=C ssh hunter2

在客户端,我成功了。

在Arch Linux中使用英国键盘和地区,我有以下错误:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_US.utf8"

在/etc/profile中导出我的locale并没有修复它。 不过,我确实通过编辑/etc/locale修复了这个问题同时启用en_US. gen。perl期望找到的Utf8语言环境,并运行local-gen。

(我使用的pac-manager使用AUR的一大堆perl模块,所以在我的特殊情况下重新安装perl将是一个麻烦。)