locale: Cannot set LC_CTYPE to default locale: No such file or directory

我们的阿里云机器是Ubuntu 11.04,经常会遇到这个问题:

1
2
3
4
5
6
7
8
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US:",
LC_ALL = (unset),
LC_CTYPE = "zh_CN.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

输入命令:

1
locale

输出结果是:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LANGUAGE=en_US:
LC_CTYPE=zh_CN.UTF-8
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

我们看到的确有两个找不到的warning,但是也不知道是为啥。最后对我真正起作用的是这个答案:Ubuntu server strange locale issue [closed]

看起来我们缺少了LC_ALL,所以我只运行了以下命令:

1
export LC_ALL=en_US.UTF-8

最后解决了问题。给大家以供参考

后注

以上也未能解决以上问题,大家可以参考这个链接 How to fix Perl warning setting locale failed on Raspbian