Warning: setlocale: LC_CTYPE: cannot change locale, setlocalelc_ctype
Setlocale warning
I have been using iterm2 on mac for some time. The following warning is always reported when I log on to the server:
Warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
Then, the LC_CTYPE environment variable is reported during yum installation. So took the time to search, find the following article http://www.cyberciti.biz/faq/os-x-terminal-bash-warning-setlocale-lc_ctype-cannot-change-locale/
The article provides three solutions:
1. Disable Set locale environment variables on startup on the ssh client.
2. sudo vi ~ /. Ssh/config comment out # SendEnv lang lc.
3. localedef-I en_US-f UTF-8 en_US.UTF-8
I have tried the first two. It's OK. The key is to understand why. In fact, when ssh is connected, it will pass the environment variable. If the variable does not have a local environment on the server, this error will be reported. I confirmed that it is actually caused by the $ LC_CTYPE environment variable.
Environment Variable LC_CTYPE = UTF-8 in mac
imac:~ aca$ echo $LC_CTYPEUTF-8imac:~ aca$ localeLANG=LC_COLLATE="C"LC_CTYPE="UTF-8"LC_MESSAGES="C"LC_MONETARY="C"LC_NUMERIC="C"LC_TIME="C"LC_ALL=
Log on to the server without passing LC Parameters
LC_CTYPE = "en_US.UTF-8" on the server"
[root@iZ28ywqw7nhZ opt]# localeLANG=en_US.UTF-8LC_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
Log on to the server by passing LC Parameters
[root@iZ28ywqw7nhZ ~]# echo "$LC_CTYPE"UTF-8[root@iZ28ywqw7nhZ ~]# localelocale: Cannot set LC_CTYPE to default locale: No such file or directorylocale: Cannot set LC_ALL to default locale: No such file or directoryLANG=en_US.UTF-8LC_CTYPE=UTF-8LC_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=
Passing parameters causes LC_CTYPE = UTF-8 on the server.
You can see that LC_CTYPE this parameter, mac above is a UTF-8, the server can not recognize the UTF-8, generally is "en_US.UTF-8", so will report cannot change locale (UTF-8 ): no such file or directory. This is the reason.