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

我该怎么解决呢?


当前回答

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

其他回答

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

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

# then regenerate
sudo locale-gen

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

这在Ubuntu中很简单。您必须从头开始生成locale,从命令行运行以下命令:

sudo locale-gen en_US en_US.UTF-8
sudo dpkg-reconfigure locales

这将创建区域设置,然后重新配置它们。

这通常意味着您还没有正确地在Linux机器上设置区域设置。

在Debian或Ubuntu上,这意味着你需要去做

$ sudo locale-gen
$ sudo dpkg-reconfigure locales

另参见man locale-gen。

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

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

在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将是一个麻烦。)