8

When I ssh into an EC2 instance running Ubuntu 18.04, I get this error:

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

I tried this but this didn't fix it:

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").

4 Answers4

6

Another option is to disable sending LC_* environment variables. Refer to https://stackoverflow.com/questions/29609371/how-do-not-pass-locale-through-ssh , these steps fits for MacOS ssh client :

sudo vi /etc/ssh/ssh_config

Find these settings:

Host *
      SendEnv LANG LC_*

Change it to :

Host *
#      SendEnv LANG LC_*

Save the file, then try connecting again.

muru
  • 197,895
  • 55
  • 485
  • 740
  • This is the right solution. – Martin Braun Jun 28 '21 at 21:38
  • LC_CTYPE should be empty by default. I don’t think a properly configured macOS should set this variable. If you see this environment variable I think people should check their macOS language configuration. – Franklin Yu Oct 26 '22 at 08:58
4

Thanks to Gunnar Hjalmarsson I'm able to use this workaround:

unset LC_CTYPE in ~/.profile

0

I don't have enough reputation to comment, but I want to build on the YudhiWidyatama answer.

Host * !host_to_omit1 !host_to_omit2
SendEnv LANG LC_*

Would be the right answer. Disabling this policy for every host seems a bit too drastic.

0

perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset)

For me work just exsport this two $ export LC_ALL=C.UTF-8 $ export LANG=C.UTF-8

Eqbkg3
  • 1