在Ubuntu Server 12.04上執行apt-get install命令時,報如下warning
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "zh_CN:zh",
LC_ALL = (unset),
LC_TIME = "zh_CN",
LC_MONETARY = "zh_CN",
LC_ADDRESS = "zh_CN",
LC_TELEPHONE = "zh_CN",
LC_NAME = "zh_CN",
LC_MEASUREMENT = "zh_CN",
LC_IDENTIFICATION = "zh_CN",
LC_NUMERIC = "zh_CN",
LC_PAPER = "zh_CN",
LANG = "zh_CN.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
|
搜了一下解決辦法,參考這篇文章,在家目錄下
|
1
|
$ vi .bashrc
|
在文件尾加入
|
1
|
export LC_ALL=C
|
保存后執行
|
1
|
$ source .bashrc
|
問題解決。
為什么這么做?
看了這篇文章了解了下locale,上面報的warning意思大概可以歸納為
- LC_ALL變量的值unset
- LC_CTYPE和LC_MESSAGES的值設置的可能有問題
先將原來添加到.bashrc中的“export LC_ALL=C”刪除,重啟客戶端會話,恢復系統到一開始的狀態
su到root查看系統locale設置
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
$ su - root
# locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=zh_CN.UTF-8
LANGUAGE=zh_CN:zh
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC=zh_CN
LC_TIME=zh_CN
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY=zh_CN
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER=zh_CN
LC_NAME=zh_CN
LC_ADDRESS=zh_CN
LC_TELEPHONE=zh_CN
LC_MEASUREMENT=zh_CN
LC_IDENTIFICATION=zh_CN
LC_ALL=
|
查看系統已安裝的locale
|
1
2
3
4
5
6
7
8
9
10
|
# locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
C
C.UTF-8
POSIX
en_US.utf8
zh_CN
zh_CN.gb2312
|
定位錯誤為 (1) LC_ALL沒設置值,(2) LC_CTYPE和LC_MESSAGES的值zh_CN.UTF-8系統未安裝
1、設置LC_ALL的值為zh_CN.UTF-8
|
1
|
# vi /etc/default/locale
|
2、執行
|
1
2
|
# cd /usr/share/locales
# ./install-language-pack zh_CN
|
安裝這個locale
問題解決。
正如這篇文章所說,LC_ALL的優先級最高,所以不執行步驟1只執行步驟2就可以解決問題。另外,為了避免locale設置成zh_CN可能帶來的稀奇古怪的錯誤,我直接將/etc/default/locale文件從這樣
|
1
2
3
4
5
6
7
8
9
10
11
|
LANG="zh_CN.UTF-8"
LANGUAGE="zh_CN:zh"
LC_NUMERIC="zh_CN"
LC_TIME="zh_CN"
LC_MONETARY="zh_CN"
LC_PAPER="zh_CN"
LC_NAME="zh_CN"
LC_ADDRESS="zh_CN"
LC_TELEPHONE="zh_CN"
LC_MEASUREMENT="zh_CN"
LC_IDENTIFICATION="zh_CN"
|
設置成這樣
|
1
2
3
4
5
6
7
8
9
10
11
|
LANG="zh_CN.UTF-8"
LANGUAGE="zh_CN:zh"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
|
