当我运行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_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

其他回答

对我来说,我通过编辑.bashrc文件,添加导出来修复这个错误。添加在最初的注释之后。

添加语言支持。

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

问题的根源

我经历过,通过ssh从一台机器登录到另一台机器。远程机器没有本地机器上的locale文件。您可以禁用区域设置从本地机器转发到远程机器(在文件/etc/ssh/sshd_config中删除AcceptEnv LANG LC_CTYPE…)或安装区域设置(在本例中不需要更改它)。

安装

我使用的Fedora、Red Hat Linux和CentOS

sudo dnf install langpacks-de

德语(de)语言包。我登出,登陆,成功了。

搜索使用的其他langpacks

dnf search langpacks-

改变/激活

列出我使用的可用区域设置

localectl list-locales

并设置一个新的

sudo localectl set-locale de_DE.utf8

以下是如何在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

另一个与git相关的答案:

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

如果您正在使用反引导创建rootfs,则需要生成区域设置。你可以通过运行:

# (optional) enable missing locales
sudo nano /etc/locale.gen

# then regenerate
sudo locale-gen

这个技巧来自https://help.ubuntu.com/community/Xen