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

我该怎么解决呢?


当前回答

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

检查哪个外壳 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

其他回答

用zsh ohmyzsh,我把这个添加到。zshrc:

 # You may need to manually set your language environment
 LANGUAGE=en_US.UTF-8
 LANG=en_US.UTF-8
 LC_CTYPE=en_US.UTF-8
 LC_ALL=en_US.UTF-8

通过删除line export LANG=en_US。utf - 8

重新打开一个新标签和SSHed,为我工作:)

perl -e exit
sudo localedef -i en_US -f UTF-8 en_DE.UTF-8
#                                   DE = German
# Use your country code en lieu of  DE

# The second "perl" should then not complain any more
perl -e exit

localectl list-locales # Just make sure it is OK

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

首先打开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

如果有人有一台带有Strato的服务器并试图找出这个问题,请检查/etc/profile.我在重新生成区域设置和设置变量太长时间之前,我发现在这个文件的末尾有两行覆盖了我的区域设置。

我在/etc/locale.conf上设置了LC_COLLATE=C。我简单地删除了这一行,因此只有LANG=en_US。设置了UTF-8(或等效的UTF-8),就不会再有问题了。