I want to understand how locales work. In particular I've read "-bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)" and https://askubuntu.com/questions/114759/warning-setlocale-lc-all-cannot-change-locale

On my Linux Mint I did locale-gen fr_FR.*, after that LC_ALL=fr_FR.UTF-8 outputs "bash: warning: setlocale: LC_ALL: cannot change locale (fr_FR.UTF-8)". However locale after that shows "LC_NAME=fr_FR.UTF-8", etc., so locale variables are changed. Why write "cannot change locale"?

I did LC_NAME=qq_QQ.UTF-8 (non-existent? locale) and the result is same - warning, locale output updated.

I've noted there is no warning only in case new assignment was already generated before that bash terminal is started. In line with that bash -c "LC_NAME=fr_FR.UTF-8" produced no warning.

Command from https://askubuntu.com/questions/114759/warning-setlocale-lc-all-cannot-change-locale sudo update-locale LANG=fr_FR did not get rid of the warning.

I have suspicion current bash session has hold of /etc/defaults/locale and other files so locale-gen has no effect on that. Correct? strace output is (yet) too complex for me to read, I only have not found /etc/defaults/locale in it.


System Linux Mint 20.2 (Ubuntu based). I've used locale-gen name.* IIRC cause I've read that line somewhere and also output showed it is exactly locales for name were done. Now upon reading the answer and man page of locale-gen I've tried to comment out name.* in /etc/locale.gen, run sudo locale-gen, then un-comment name.UTF-8 back and run sudo locale-gen again. The result is same as before when running locale-gen name.*

1 Answer 1


Your warning suggests that the locales you are requesting have not actually been compiled. So, you should use:

sudo dpkg-reconfigure locales

to select the locales to compile.

Alternatively, just edit the file:


and uncomment the locales you want, then run:

sudo locale-gen

to generate them.

What are the locale variables?

The locale environment variables are just regular environment variables that have been assigned a special meaning by the C library (glibc). Specifically, those variables will be used when a program requests activation of localization support by calling setlocale(LC_ALL, ""); or similar. At that point, the C library will load the appropriate localization settings from /usr/lib/locale/.

These localization settings are pre-compiled by the localedef utility using the locale source data in /usr/share/locale. In Debian, Ubuntu and related distributions, localedef is called by locale-gen.

Why locale-gen fr_FR.* does not work

locale-gen does not take any arguments from the command line. It only reads /etc/locale.gen to determine which locale(s) to generate. So depending on which locales are uncommented in your /etc/locale.gen file, your locale-gen fr_FR.*command may have had no desired effect.

The update-locale command is just a tool for package maintainer scripts to update the system-wide default locale environment variable settings in /etc/default/locale. It has no effect at all on which locales are actually going to be compiled.

  • Thanks for explaining mystery of sudo dpkg-reconfigure locales . However your last paragraph (un-commenting name.UTF-8; locale-gen) is not working - warning is there for LC_NAME=name.UTF-8. And not there when run via bash -c. Please see "Added" to the question. Commented Dec 21, 2022 at 10:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .