• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

解决perl:warning:Settinglocalefailed.

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

在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"

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
perl调试发布时间:2022-07-22
下一篇:
Eclipse+EPIC搭建Perl开发环境发布时间:2022-07-22
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap