perl: warning: Setting locale failed.引发的问题

缘由

我用的是linode的vps,系统为ubuntu14.04lts
当apt-get安装软件时,都会报一个相同的错误,如下

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_TIME = "zh_CN.UTF-8",
    LC_MONETARY = "zh_CN.UTF-8",
    LC_ADDRESS = "zh_CN.UTF-8",
    LC_TELEPHONE = "zh_CN.UTF-8",
    LC_NAME = "zh_CN.UTF-8",
    LC_MEASUREMENT = "zh_CN.UTF-8",
    LC_IDENTIFICATION = "zh_CN.UTF-8",
    LC_NUMERIC = "zh_CN.UTF-8",
    LC_PAPER = "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").

那是因为安装软件时,都会去执行一个update-locale的命令,用来更新locale
这个命令是一个脚本,用perl写的,可以用whereis update-locale查到,位置在/usr/sbin/update-locale

上述报错并不是因为update-locale命令而引起,update-locale这段脚本没有问题,而是因为perl
可以使用以下命令测试:

perl -e exit

其实,真正的原因是perl为系统使用zh_CN.UTF-8,但系统不知道zh_CN.UTF-8是什么东西

解决方法

解决方法也很简单

apt-get install language-pack-zh-hans

安装一个中文语言,系统就知道zh_CN.UTF-8了,这个时候用perl就不会报错了

深入了解

这种情况一般是vps比较常见,因为一般都是用ssh的方式连接到vps上的
sshd有这个机制,会把客户机上的语言环境带到远程的机器上
客户机一般都会设置zh_CN.UTF-8语言,用来显示中文,而远端的vps一般就只有en_US.UTF-8
zh_CN.UTF-8一旦带过去就会报找不到的错误,文章开头已经说的很清楚了

不靠谱的解决方法

网上还有些解决方法,并不是很靠谱,虽然从表面来看像解决问题了,但其实是把问题影藏了

比如在远程主机上的/etc/ssh/sshd_config文件里,将AcceptEnv LANG LC_*这行注释掉
然后重启远程的sshd,然后退出远程后,重新ssh上来。
这时,远程主机不会把客户机的语言环境(zh_CN.UTF-8)带过来
当然就不会再有报错,可惜的是,远程主机是无法正确显示中文的,问题还在,只是被影藏了。

时间: 2024-10-09 11:58:18

perl: warning: Setting locale failed.引发的问题的相关文章

perl:warning:Setting locale failed解决办法

perl:warning:Setting locale failed解决办法: $ sudo vi /etc/profile 按a或i进入编辑模式 export LC_ALL=en_US.UTF-8export LANGUAGE=en_US.UTF-8 按Esc键退出编辑模式 :wq (保存并退出) $ source /etc/profile perl:warning:Setting locale failed解决办法,布布扣,bubuko.com

zsh解决perl: warning: Setting locale failed.

错误如下: perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LANG = "en_US.UTF-8" are supported and installed on your system. perl: warning: Falling back to the standard

perl: warning: Setting locale failed.

本篇文章由:http://xinpure.com/perl-warning-setting-locale-failed/ 将 mac 系统切换成英文后,使用 git 命令出现如下错误: perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LC_CTYPE = "UTF-8", L

perl: warning: Falling back to the standard locale ("C").   (Ubuntu repo sync 报错)

报错::perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LANG = "en_IE.UTF-8" are supported and installed on your system. perl: warning: Falling back to the standard l

解决:perl: warning: Please check that your locale settings

问题: perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LC_CTYPE = "zh_CN.UTF-8", LC_TERMINAL_VERSION = "3.3.3beta2", LC_TERMINAL = "iTerm2", LANG

pve proxmox 常见问题,perl warning

pve命令,如下报错 perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LC_CTYPE = "UTF-8", LANG = "en_US.UTF-8" are supported and installed on your system. perl: wa

简单解决Ubuntu修改locale的问题

本文针对的问题是"Ubuntu 安装中文语言包""Ubuntu Server中文问题","Ubuntu更改语言环境","Ubuntu locale的设定","cannot change locale (zh_CN.UTF-8)","Linux中文乱码","Linux字符集的修改","Linux乱码的解决办法"等问题,提供一站式解决.如果系统显示中文

Please check that your locale settings问题

问题描述: perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = "en_US:en", LC_ALL = (unset), LC_CTYPE = "zh_CN.UTF-8", LANG = "en_US.UTF-8" are supported and installed on your sy

mysql 多实例安装

[[email protected] ~]#rm -f /etc/init.d/mysqld [[email protected] ~]# mkdir -p /data/{3306,3307}/data [[email protected] Packages]# rpm -ivh tree-1.5.3-2.el6.x86_64.rpm warning: tree-1.5.3-2.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID c105