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

我该怎么解决呢?


当前回答

另一个与git相关的答案:

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

其他回答

导出变量

$ export LANGUAGE=en_US.UTF-8
$ export LC_ALL=en_US.UTF-8
$ export LANG=en_US.UTF-8
$ export LC_CTYPE=en_US.UTF-8

下一个运行

$ sudo locale-gen
$ sudo dpkg-reconfigure locales 

当您运行dpkg-reconfigure locale时,它会要求您选择locale,选择en_US。utf - 8。如果通过选择所有区域设置来运行此操作,则需要一些时间来配置。

对我来说,我通过编辑.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

我在Mac M1 Monterey上试过这些方法,但都不行。 禁用该消息的快速方法是: 打开终端->首选项->高级选项卡->取消勾选以在启动时设置区域环境变量

ssh默认覆盖LC区域变量。看到/etc/ssh/sshd_config:

AcceptEnv LANG LC_*

也许你需要在本地shell中设置这些变量。

每当我在最新的Kali Linux版本上运行Perl脚本(比如enum4linux)时,都会遇到这个问题。

kali@kali:~$ lsb_release -a
No LSB modules are available.
Distributor ID:    Kali
Description:    Kali GNU/Linux Rolling
Release:    2020.3
Codename:    kali-rolling
kali@kali:~$

例如,

kali@kali:~$ enum4linux
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_ADDRESS = "ms_MY.UTF-8",
    LC_NAME = "ms_MY.UTF-8",
    LC_MONETARY = "ms_MY.UTF-8",
    LC_PAPER = "ms_MY.UTF-8",
    LC_IDENTIFICATION = "ms_MY.UTF-8",
    LC_TELEPHONE = "ms_MY.UTF-8",
    LC_MEASUREMENT = "ms_MY.UTF-8",
    LC_TIME = "ms_MY.UTF-8",
    LC_NUMERIC = "ms_MY.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").
enum4linux v0.8.9 (http://labs.portcullis.co.uk/application/enum4linux/)
Copyright (C) 2011 Mark Lowe (mrl@portcullis-security.com)

请看给出的警告信息。

perl: warning: Falling back to a fallback locale ("en_US.UTF-8").

另外,注意LC_ALL = (unset)

解决办法很简单。你所要做的就是设置它。

export LC_ALL=en_US.UTF-8

例如,

kali@kali:~$ export LC_ALL=en_US.UTF-8
kali@kali:~$

问题解决了

kali@kali:~$ enum4linux
enum4linux v0.8.9 (http://labs.portcullis.co.uk/application/enum4linux/)
Copyright (C) 2011 Mark Lowe (mrl@portcullis-security.com)

对于永久解决方案,您可能希望将其添加到.bashrc文件中。