您尚未登录。

#1 2016-07-05 15:31:15

lostyear
会员
注册时间: 2015-04-09
帖子: 11

locale错误,locale: Cannot set LC_* to default locale: No such file o

发现部分软件无法使用,提示LC_*有问题,于是看了locale

root@Arch ~ # 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=en_US.UTF-8
LC_CTYPE="en_US.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=
root@Arch ~ # 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
POSIX
en_DK.utf8
es_US.utf8
zh_CN.utf8

我尝试了一下重设locale

root@Arch ~ # cat /etc/locale.gen | grep -vn "^#"
146:en_DK.UTF-8 UTF-8
206:es_US.UTF-8 UTF-8
473:zh_CN.UTF-8 UTF-8
root@Arch ~ # locale-gen
Generating locales...
  en_DK.UTF-8... done
  es_US.UTF-8... done
  zh_CN.UTF-8... done
Generation complete.
root@Arch ~ # localectl set-locale LANG=en_US.UTF-8 LC_COLLATE=C LC_TIME=en_DK.UTF-8 LC_CTYPE=zh_CN.UTF-8 LC_MESSAGES=C
root@Arch ~ # cat /etc/locale.conf
LANG=en_US.UTF-8
LC_CTYPE=zh_CN.UTF-8
LC_TIME=en_DK.UTF-8
LC_COLLATE=C
LC_MESSAGES=C

locale.conf文件的设置是根据wiki上的locale页面和上面的错误信息设置的。
但是这样设置完成以后还是不对。
locale命令的输出是这样的:

root@Arch ~ # locale
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LC_CTYPE=zh_CN.UTF-8
LC_NUMERIC="en_US.UTF-8"
LC_TIME=en_DK.UTF-8
LC_COLLATE=C
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES=C
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=
root@Arch ~ # locale -a
C
POSIX
en_DK.utf8
es_US.utf8
zh_CN.utf8

安装软件也会提示mandb: can't set the locale; make sure $LC_* and $LANG are correct


然后尝试手动export LC_ALL

root@Arch ~ # export LC_ALL=en_US.UTF-8
root@Arch ~ # 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
POSIX
en_DK.utf8
es_US.utf8
zh_CN.utf8
root@Arch ~ # 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=en_US.UTF-8
LC_CTYPE="en_US.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=en_US.UTF-8
root@Arch ~ # export LC_ALL=C
root@Arch ~ # locale -a
C
POSIX
en_DK.utf8
es_US.utf8
zh_CN.utf8
root@Arch ~ # locale
LANG=en_US.UTF-8
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_PAPER="C"
LC_NAME="C"
LC_ADDRESS="C"
LC_TELEPHONE="C"
LC_MEASUREMENT="C"
LC_IDENTIFICATION="C"
LC_ALL=C
root@Arch ~ # tmux
tmux: need UTF-8 locale (LC_CTYPE) but have ANSI_X3.4-1968

export设置LC_ALL=en_US.UTF-8错误依旧,设置LC_ALL=C虽然不报错,但是会有些软件因为locale不是utf8而无法使用(上面的tmux)。

技穷了,现在locale到底该怎么设置啊?

离线

#2 2016-07-05 18:48:24

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,956
个人网站

Re: locale错误,locale: Cannot set LC_* to default locale: No such file o

en_US.UTF-8: 美式英语
es_US.UTF-8: 美式西班牙语

离线

#3 2016-07-05 19:25:15

lostyear
会员
注册时间: 2015-04-09
帖子: 11

Re: locale错误,locale: Cannot set LC_* to default locale: No such file o

可以了,感谢。。。
居然是选错了,是时候配一副新的眼镜了!

离线

页脚