[Mac] -bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory

Tadashi Shigeoka ·  Sat, April 4, 2015

When ssh-ing to an external server from Mac’s Terminal app, this warning message appeared: -bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory.

$ ssh codenote.net
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory

In this state, errors also occur when entering the mongo shell, so you need to export LC_ALL=C, which is a bit troublesome.

$ mongo mydb
Failed global initialization: BadValue Invalid or no user locale set. 
Please ensure LANG and/or LC_* environment variables are set correctly.

Unchecking the Set locale environment variables on startup checkbox will stop the warning message from appearing.

Terminal-Profiles-Set-locale-env

For me, this error started occurring when I changed my Mac’s language settings from Japanese to English.

If you’re troubled by similar problems, you might want to check your Terminal app settings.

That’s all from the Gemba.