/ iTerm2

iTerm2

manpath: can't set the locale; make sure $LC_* and $LANG are correct

Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-32-generic x86_64)

Welcome to aliyun Elastic Compute Service!

Last login: Tue Jul 5 09:47:04 2016 from 101.81.225.194
manpath: can't set the locale; make sure $LC_* and $LANG are correct

➜  ~ 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
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=
  • 错误在于 LC_CTYPE=UTF-8,正确的应该是 LC_CTYPE=en_US.UTF-8
  • LC_ALL= 是躺枪的

原因

Your local ssh client is sending your LC_* environment variables to remote sshd server. In other words, SSH will try to set every LC_* variable you have set on your local OSX system on the remove server too.

解决办法

方法一:Preventing OpenSSH Client from sending the LC_* variables on OS X / Linux / Unix desktop(推荐)

Edit /etc/ssh/ssh_config or /etc/ssh_config file, enter:

sudo vi /etc/ssh/ssh_config

SendEnv LANG LC_* 注释掉保存后,重新登录服务器就不会报错了。

方法二:If you are using the Terminal app on OS X

iTerm2 默认启用了“Set locale environment variables on startup”
取消勾选可以解决服务器上的问题,但是本地就会有中文显示的问题。可以每次手动修改 iTerm2 的配置。

方法三: Install required locale on the remote server

Finally, you can fix this problem either installing the desired locale using the localedef command, or consider choosing a different locale in locale/remote system:

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