I have the exact question as this but there's no solution. I tried but it doesn't work
$ 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:
Generate missing locales and select your desired default with:
I had the similar issue and added the below lines in my
/etc/default/locale
file:I got this from this post: How do I fix my locale issue?
This commands saved my life
The output from the
locale
command indicates that you have this incorrect line in your environment:("UTF-8" is not a valid locale name.)
It typically comes from
/etc/default/locale
. Please remove that line, if it's there, and relogin.If it does not come from there, it can come from your shell configuration, or if you're logged in remotely via SSH, from the configuration of the client machine.
The /etc/default/locale file can have additional (but unnecessary) lines: Example file can look like this:
To sort out and successfully generate and reconfigure locales, remove or comment out all lines from this file except:
The file should finally look like:
After this, run
dpkg-reconfigure locales
, select en_US.UTF-8 when prompted for selecting the locale, and you should be good to go. You'll receive aGeneration complete.
message when the process is complete.I had the same problem on Pi-OS bullseye. What worked for me was editing
/etc/default/locale
.I've added the line (at least for german):
Then re-login and simply
did the job - no errors after this