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

我该怎么解决呢?


当前回答

将LC_TYPE环境变量设置为默认的区域语言“C”将有助于消除此警告。

执行export LC_CTYPE="C",然后尝试执行perl命令。

附注:您需要在/etc/environment文件或/etc/default/locale文件中设置此变量以获得永久解决方案。

其他回答

将缺失的地区添加到.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

尝试重新安装:

localess apt-get install --reinstall locales

更多信息请参见如何更改默认区域设置

对于任何从iTerm2连接到DigitalOcean或其他云托管提供商的人。在macOS v10.13 (High Sierra)上运行app,在一些命令上得到这个错误:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_CTYPE = "UTF-8",
    LANG = "en_US.UTF-8"
  are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").

这为我解决了问题:

对我来说,在Ubuntu 16.04 (Xenial Xerus)上,以下工作:

root@host:~#locale-gen en_GB.UTF-8
root@host:~#localectl set-locale LANG=en_GB.UTF-8,LC_ALL=en_GB.UTF-8

然后重新启动…

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

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

# then regenerate
sudo locale-gen

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