Fixed message error: “-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory”

I have notied error message on login ssh screen:

“ -bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory”

At my searching in search engine. I have found about message and some people mention ways fixed it, as below.

  1. Adding content below to file /etc/environment .
LANG=en_US.utf-8
LC_ALL=en_US.utf-8

2. Create local file manual with command.

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

3. For my use case is using iTerm2’s on MacOS, above can’t fixed. I must have setting iTerm2 in Preference → Profile → Terminal → Envionment . Unchecked Set local variables automaticallty

Thank you.

Refers: https://gist.github.com/nicks9188/a19f39d62780055a68c22b89a9799c25

--

--