我每次执行诸如启动或停止服务之类的操作时都会收到此消息。
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US:en",
LC_ALL = (unset),
LC_MESSAGES = "en_US.UTF-8",
LANG = "en_US.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
(Reading database ... 21173 files and directories currently installed.)
Removing bind9 ...
* Stopping domain name service... bind9 [ OK ]
Processing triggers for man-db ...
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
首先运行locale
列出当前用户帐户当前定义的语言环境:
$ locale
LANG=C
LANGUAGE=
LC_CTYPE=fi_FI.UTF-8
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE=fi_FI.UTF-8
LC_MONETARY="C"
LC_MESSAGES=fi_FI.UTF-8
LC_PAPER="C"
LC_NAME="C"
LC_ADDRESS="C"
LC_TELEPHONE="C"
LC_MEASUREMENT="C"
LC_IDENTIFICATION="C"
LC_ALL=
然后生成缺少的区域设置并重新配置区域设置以注意:
$ sudo locale-gen "en_US.UTF-8"
Generating locales...
en_US.UTF-8... done
Generation complete.
$ sudo dpkg-reconfigure locales
Generating locales...
en_US.UTF-8... up-to-date
Generation complete.
现在您将不会再看到任何错误!
答案2
以上建议对我而言都不起作用(Ubuntu Server 12.04LTS)。最终有帮助的是将以下内容放入文件/etc/environment
:
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
由于某种原因,它丢失了。locale 和其他命令的输出看起来就像变量已正确定义。换句话说,不要想当然地认为所有基本内容都在应该声明的地方声明了。
答案3
它们应该在发出以下命令后消失:
sudo locale-gen en_US en_US.UTF-8
sudo dpkg-reconfigure locales
dpkg-reconfigure
在已安装软件包后重新配置它们。将要重新配置的软件包的名称传递给它。它会询问配置问题,就像第一次安装软件包时一样。
答案4
如果您进行远程连接,这是一个常见问题,因此解决方案是不转发您的语言环境。编辑/etc/ssh/ssh_config
并注释掉该SendEnv LANG LC_*
行。