Cannot set LC_CTYPE to default locale: No such file or directory

I have the exact question as this but there's no solution. I tried but it doesn't work

How do I fix my locale issue?

$ 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=
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=

$ locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
C
C.UTF-8
en_US.utf8
POSIX

Is this because of en_US.UTF-8 and en_US.utf8 mismatch?

How to fix?


This same problem (LC_CTYPE=UTF-8, which is wrong) can happen when you login over ssh from a Mac to a linux box, and your terminal automatically sets environment variables. There's a checkbox for that. Uncheck it, and you're good to go.

In iTerm it's in the profile -> Terminal tab.

In Terminal, it's in the Terminal -> Preferences -> Profiles -> Advanced tab.


Open terminal and fire the below command:

export LC_ALL="en_US.UTF-8"

I had the similar issue and added the below lines in my /etc/default/locale file:

LC_CTYPE="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
LANG="en_US.UTF-8"

I got this from this post: How do I fix my locale issue?


Generate missing locales and select your desired default with:

sudo dpkg-reconfigure locales

export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
sudo dpkg-reconfigure locales