- Having the terminal complain about invalid locale settings:
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
LANGUAGE=en_US:en
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=
- Being unable to correctly type some characters (such as accented characters).
- Having programs that tunnel their traffic over SSH, such as Subversion, complain about invalid locale settings during their operations:
svnserve: warning: cannot set LC_CTYPE locale
svnserve: warning: environment variable LC_CTYPE is UTF-8
svnserve: warning: please check that your locale name is correct
svnserve: warning: cannot set LC_CTYPE locale
svnserve: warning: environment variable LC_CTYPE is UTF-8
svnserve: warning: please check that your locale name is correct
In fact, if you look for example at the output of the locale command seen previously, you can see how the LC_CTYPE variable is set UTF-8 while all other LC_* variables (excluding the empty LC_ALL), are set to en_US.UTF-8 (which are correct according to that server settings).
What is the SSH client shipped with Lion doing? Apparently sending incorrect values to the server. It's not just a nuisance having to fix them after logging in, provided you're able to do so: this behaviour is breaking other programs tunnelling their traffic over SSH, such as Subversion, that aren't establishing an interactive SSH tunnel for the user.
Fortunately, the fix is quick: just tell the SSH client not to send any LC_* variable:
- Open the SSH client configuration file (/etc/ssh_config).
- Comment out the line that instructs the SSH client to send those variables (SendEnv LANG LC_*) from the general host configuration section (Host *). You should end up with the following fragment:
Host *
# SendEnv LANG LC_*
The configuration change will be immediately applied to any SSH session opened from now on.
Hope this helps.
Thanks for the help :)
ReplyDeleteYou're welcome. ;)
DeleteMany thanks
ReplyDeleteYou're welcome, I'm glad it helped.
DeleteThis helped solve my problem. Thanks!
ReplyDeletewow, finally correct characters in ssh screen irssi session! thanks
ReplyDeleteYou're welcome.
DeleteThank you for helping fix this issue!
ReplyDeleteTom, you're welcome.
DeleteThanks. It works for Mountain Lion as well.
ReplyDeleteYou're welcome, thanks for the report.
DeleteThanks for writing this up.
ReplyDeleteYou're welcome, I'm glad it helped.
DeleteWow! I didn't expect to find such a precise solution when I googled "Mac LC_CTYPE polluting SSH." Now I have to go and delete all the /etc/default/locale files I've created on my servers.
ReplyDeleteTalk about a subtle root cause!
Hi Kevin, you're welcome, and I'm really glad this post helped you!
Deleteawesome .. made my day!
ReplyDeleteYou're welcome, I'm glad it helped!
DeleteThanks, this fix worked for me.
ReplyDeleteNice to hear that, I'm glad it helped you!
DeleteThanks, this helped me too.
ReplyDeleteYou're welcome! Glad it helped.
DeleteThanks a lot! It finally solves this little annoying problem!
ReplyDeleteI'm glad it helped you, Leo.
DeleteGreat post. Thanks a lot. :)
ReplyDeleteYou're welcome Lalo.
DeleteThank you! This has bugged me for months!
ReplyDeleteYou're welcome Dennis.
DeleteThanks, it works on Mavericks 10.9.3 terminal.app ssh-ing into Linux RHEL 6.4 too
ReplyDeleteDharmesh Shah
Finally, a solution to my problems. Irssi will be fun again. Thank yu!
ReplyDeleteThanks!
ReplyDeleteFirst post is from 2012 and it still helped today!
ReplyDeleteThanks!
Aaaaaah! *That* was it!!!!! A million thanks.
ReplyDeleteThanks Grey. Appreciate it.
ReplyDelete+1
ReplyDeleteThanks for the quick fix!
ReplyDelete