BadValue Invalid or no user locale set. Please ensure LANG and/or LC_* environment variables are set correctly
Solution 1
Generating locales
Missing locales are generated with locale-gen:
locale-gen en_US.UTF-8
Alternatively a locale file can be created manually with localedef:[1]
localedef -i en_US -f UTF-8 en_US.UTF-8
Setting Locale Settings
The locale settings can be set (to en_US.UTF-8
in the example) as follows:
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
dpkg-reconfigure locales
The dpkg-reconfigure locales
command will open a dialog under Debian for selecting the desired locale. This dialog will not appear under Ubuntu. The Configure Locales in Ubuntu article shows how to find the information regarding Ubuntu.
Solution 2
you can use the below command on terminal
export LC_ALL=C
Solution 3
vim /etc/default/locale
add to it:
LC_ALL="en_US.UTF-8"
Solution 4
Amazon Linux AMI
Permanent solution for ohmyzsh:
$ vim ~/.zshrc
Write there below:
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
Update changes in current shell by: $ source ~/.zshrc
Solution 5
adding the following lines to my /etc/environment file worked
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
Majid Zandi
python developer. (Don’t worry about your choices: just build something.)
Updated on November 18, 2020Comments
-
Majid Zandi over 3 years
When I run
mongo
, I get the warning:Failed global initialization: BadValue Invalid or no user locale set. Please ensure LANG and/or LC_* environment variables are set correctly.
-
Majid Zandi over 9 yearsThanks! thomas-krenn.com/en/wiki/…
-
benek almost 8 yearsTo have it in all seasons : echo "export LC_ALL=C" >> ~/.bashrc
-
Damien Romito almost 8 yearsThe other answers are not permanent solutions. We have to enter those commands each time we connect. Edit that file only once is the perfect solution! Thank you
-
lingyfh almost 8 yearsOnly execute on your terminal. not server
-
Philipp Jahoda over 7 yearsThis is the only permanent solution that worked for me. Definitely deserves more upvotes!
-
GeekHades over 7 yearsThis way just for current seesion, Just for one time, Not for forever!
-
BorisS about 7 yearsWorked. Importing thing to note is that you need to logout and login again in order for this to work.
-
Nidhin David over 6 yearshi, I have accidently downvoted this question and missed it. Now I cannot remove it. It says my vote is locked. I 'am really sorry. If there is any other way, let me know.
-
DLight over 6 yearsFor those wondering: What does “LC_ALL=C” do? unix.stackexchange.com/questions/87745/what-does-lc-all-c-do
-
Habib over 5 yearsHow to save this file?
-
Mirko almost 5 yearsThis did it for me on a raspberry: sudo localedef -i en_US -f UTF-8 en_US.UTF-8 Thank you!!