Linux Tips & Tricks · October 23, 2021

Debian locale reconfigure

[Debian] Can’t set the locale; make sure $LC_* and $LANG are correct

If you get “can’t set the locale” error in your Debian system (or Debian based systems like Ubuntu, Kali, Mint), you can follow this guide. Hope it helps.

Debian ships locales without compiling them. With this approach, you use your disk space more efficiently. Since locales shipped as a source and assumed that you won’t be using more than a few, Debian asks you to compile them.

Debian can't set locale error
Debian can’t set locale error

To get rid of this error, simply call “dpkg-reconfigure locales” command. This will bring up a TUI (Text User Interface).

dpkg-reconfigure locales
dpkg-reconfigure locales

Follow the steps in TUI and you’ll get an output similar to this:

root@debian:~# dpkg-reconfigure locales
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = "en_US:en",
	LC_ALL = (unset),
	LC_ADDRESS = "tr_TR.UTF-8",
	LC_NAME = "tr_TR.UTF-8",
	LC_MONETARY = "tr_TR.UTF-8",
	LC_PAPER = "tr_TR.UTF-8",
	LC_IDENTIFICATION = "tr_TR.UTF-8",
	LC_TELEPHONE = "tr_TR.UTF-8",
	LC_MEASUREMENT = "tr_TR.UTF-8",
	LC_TIME = "tr_TR.UTF-8",
	LC_NUMERIC = "tr_TR.UTF-8",
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
locale: Cannot set LC_ALL to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_ALL to default locale: No such file or directory
Generating locales (this might take a while)...
  en_US.UTF-8... done
  tr_TR.UTF-8... done
Generation complete.
root@debian:~# man dpkg
root@debian:~# echo $LC_ALL
en_US.UTF-8
root@debian:~# echo $LANG
en_US.UTF-8
root@debian:~# echo $LC_NAME
tr_TR.UTF-8
root@debian:~# echo $LC_MEASUREMENT 
tr_TR.UTF-8
root@debian:~# echo $LC_TIME
tr_TR.UTF-8

This should help you solving “make sure $LC_* and $LANG are correct” error.