manpath:无法设置语言环境;请确保 $LC_* 和 $LANG 正确

manpath:无法设置语言环境;请确保 $LC_* 和 $LANG 正确

当我ssh进入运行 Ubuntu 18.04 的 EC2 实例时,出现此错误:

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

我尝试了这个但是没有解决问题:

sudo locale-gen "en_US.UTF-8"
sudo dpkg-reconfigure locales
Generating locales (this might take a while)...
  en_US.UTF-8... done
Generation complete.
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_TERMINAL_VERSION = "3.3.7",
    LC_CTYPE = "UTF-8",
    LC_TERMINAL = "iTerm2",
    LANG = "C.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("C.UTF-8").
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
/usr/bin/locale: Cannot set LC_CTYPE to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_ALL to default locale: No such file or directory
Generating locales (this might take a while)...
  en_US.UTF-8... done
Generation complete.
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_CTYPE = "UTF-8",
    LC_TERMINAL_VERSION = "3.3.7",
    LC_TERMINAL = "iTerm2",
    LANG = "C"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_CTYPE = "UTF-8",
    LC_TERMINAL_VERSION = "3.3.7",
    LC_TERMINAL = "iTerm2",
    LANG = "C"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

答案1

另一个选项是禁用发送 LC_* 环境变量。请参阅https://stackoverflow.com/questions/29609371/how-do-not-pass-locale-through-ssh,这些步骤适用于 MacOS ssh 客户端:

sudo vi /etc/ssh/ssh_config

找到这些设置:

Host *
      SendEnv LANG LC_*

更改为:

Host *
#      SendEnv LANG LC_*

保存文件,然后尝试再次连接。

答案2

谢谢古纳尔·哈尔马松我能够使用这个解决方法:

unset LC_CTYPE~/.profile

答案3

我没有足够的声誉来发表评论,但我想在 YudhiWidyatama 的回答基础上进行构建。

Host * !host_to_omit1 !host_to_omit2
SendEnv LANG LC_*

是正确的答案。禁用每个主机的此策略似乎有点太过分了。

答案4

perl:警告:请检查您的语言环境设置:LANGUAGE =(取消设置), LC_ALL = (取消设置

对于我来说,工作只是导出这两个 $ export LC_ALL=C.UTF-8 $ export LANG=C.UTF-8

相关内容