warning: setlocale: LC_CTYPE: cannot change locale

setlocale warning

使用mac上面iterm2一段时间了,登陆服务器老是报如下warning

warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory

然后yum 安装的时候也会报LC_CTYPE环境变量的问题。于是抽空搜索了一下,找到了如下文章http://www.cyberciti.biz/faq/os-x-terminal-bash-warning-setlocale-lc_ctype-cannot-change-locale/

文章给出了3个解决方案:

1. ssh client关掉 Set locale environment variables on startup。

2. sudo vi ~/.ssh/config 将#SendEnv LANG LC_* 给注释掉。

3. localedef -i en_US -f UTF-8 en_US.UTF-8

前2个我都试过了,是ok 的,关键是理解why为什么。其实ssh 连的时候他会传递环境变量,这个变量如在服务器没有本地的环境,就会报这个错误。我确认了一下,其实就是$LC_CTYPE 这个环境变量导致的。

在mac的环境变量LC_CTYPE=UTF-8

imac:~ aca$ echo $LC_CTYPE
UTF-8
imac:~ aca$ locale
LANG=
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=

不传LC参数登陆服务器

在服务器上面LC_CTYPE=”en_US.UTF-8”

[root@iZ28ywqw7nhZ opt]# locale
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@iZ28ywqw7nhZ opt]# echo $LC_CTYPE

传LC参数登陆服务器

[[email protected] ~]# echo "$LC_CTYPE"
UTF-8
[[email protected] ~]# locale
locale: Cannot set LC_CTYPE 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=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=

传参数导致服务器上面的LC_CTYPE=UTF-8了。

可以看到注意是LC_CTYPE这个参数,mac上面是UTF-8,服务器上面识别不了UTF-8,一般都是”en_US.UTF-8” ,所以会报cannot change locale (UTF-8): No such file or directory 这个warning 。原因在此。

时间: 2024-10-08 10:22:14

warning: setlocale: LC_CTYPE: cannot change locale的相关文章

-bash: warning: setlocale: LC_CTYPE: cannot change locale (EN_US.UTF-8)

最近发现MDT推出去的系统的有不同问题,其问题就不说了,主要是策略权限被域继承了.比如我们手动安装的很多东东都是未配置壮态,推的就默认为安全壮态了,今天细找了一下,原来把这个关了就可以了. -bash: warning: setlocale: LC_CTYPE: cannot change locale (EN_US.UTF-8)

终端SSH远程连接CentOS报错:-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory

终端SSH远程连接CentOS时,报以下错误提示: -bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory 在centos服务器上 sudo vim /etc/locale.conf 内容如下: LC_ALL=en_US.utf8 LC_CTYPE=en_US.utf8 LANG=en_US.utf8 重新连接就正常了. 原文地址:https://www.cnblog

Mac iTerm2登陆CentOS提示warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory

[报错原因]:没有utf-8这个语系(没添加语言_国名前缀),LC_ALL又没设定值. 在 /etc/environment 加入以下两行,重新登陆即可. LANG=en_US.utf-8 LC_ALL=en_US.utf-8 原文地址:https://www.cnblogs.com/imzye/p/8503576.html

CentOS -bash: warning: setlocale: LC_MESSAGES: cannot change locale (en_US.UTF-8)

centos5.x 登陆显示: -bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory-bash: warning: setlocale: LC_COLLATE: cannot change locale (en_US.UTF-8): No such file or directory-bash: warning: setlocale: LC_MESSAG

/bin/sh: warning: setlocale: LC_ALL: cannot change locale (zh_CN.UTF-8) centos7

今天登陆centos 7 遇到一个 警告 /bin/sh: warning: setlocale: LC_ALL: cannot change locale (zh_CN.UTF-8) bash : warning: setlocale: LC_ALL: cannot change locale (zh_CN.UTF-8) 只要执行 : yum -y install kde-l10n-Chinese telnet && yum -y reinstall glibc-common #基本就能

登陆报错:-bash: warning: setlocale: LC_CTYPE: cannot c

Xshell登录linux系统时会出现报错:-bash: warning: setlocale: LC_CTYPE: cannot change locale (latin1): No such file or directory-bash: warning: setlocale: LC_COLLATE: cannot change locale (latin1): No such file or directory-bash: warning: setlocale: LC_MESSAGES:

LC_CTYPE: cannot change locale (en_US.

升级glibc库后,使用SecureCRT登录linux,提示: ast login: Mon Feb 20 02:03:21 2017 from 192.168.4.187 -bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory -bash: warning: setlocale: LC_COLLATE: cannot change locale (en

ssh登录locale报错:cannot change locale (zh_CN.UTF-8): No such file or directory

一.登录ssh报错: Last login: Tue Apr 23 03:42:01 2019 from 172.28.146.109 -bash: warning: setlocale: LC_ALL: cannot change locale (en_CN.UTF-8): No such file or directory -bash: warning: setlocale: LC_ALL: cannot change locale (en_CN.UTF-8) -bash: warning:

strlen, wcslen, _mbslen, _mbslen_l, _mbstrlen, _mbstrlen_l, setlocale(LC_CTYPE, "Japanese_Japan")(MSDN的官方示例)

// crt_strlen.c // Determine the length of a string. For the multi-byte character // example to work correctly, the Japanese language support for // non-Unicode programs must be enabled by the operating system. #include <string.h> #include <local