I just installed CentOS 6 and whenever I login to the system via SSH remotely, I get the following error:

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

When I type "locale" on the command line, I get the following output:

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=

What can be the problem? How can I solve this issue?

link|improve this question

55% accept rate
feedback

4 Answers

up vote 1 down vote accepted

On the server you ssh from do you have a locale set via an environment variable? In looking at my Centos 6 installation, the only locale that I can find supported is identified as "en_US.utf8" (discovered using locale -a command). Could this be the problem?

In my testing, when I set the LC_ALL environment variable to "en_US.UTF-8", ssh'd to the server, the output of my locale command was set to "POSIX" in my case. This the same as when I have NOT set (i.e. unset) the LC_ALL variable before ssh'ing.

When I set my LC_ALL variable to "en_US.utf8" or "en_US.utf-8", ssh'd to my Centos 6 box, the output of the locale was the same as what was set on the source box.

Notice I used no caps for UTF also.

link|improve this answer
By the way, I noticed that this was occurring from my Mac OS X Lion ssh settings. I edited /etc/ssh_config file and commented SendEnv LANG LC_*. It solved my problem. – Cem Oct 28 '11 at 12:30
feedback

This was my fix in the past for locale errors.

Run the following: locale-gen

Then edit /etc/locale.gen. Make sure the following is uncommented:

en_US.UTF-8 UTF-8
en_US ISO-8859-1

generate locale.

locale-gen

link|improve this answer
feedback

solved this by disabling "Set locale environment variables on startup" in Terminal Settings > Advanced

Here is a screenshot https://skitch.com/neslob/g9gr2/settings

link|improve this answer
feedback

On a local Centos 6.2 system: This did not help: localedef -i en_US -f UTF-8 en_US.UTF-8

This worked: localedef --no-archive -i en_US -f UTF-8 en_US.UTF-8

I also deleted locale-archive in: /usr/lib/locale I do not know if this was necessary

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.