Fix Error “Locale: Cannot Set LC_ALL to default locale: No such file or directory”
Have you ever came across the error “locale: Cannot Set LC_ALL to default locale: No such file or directory” in Linux then this blog post is for you. Here You can find the solution for the error “locale: Cannot Set LC_ALL to default locale: No such file or directory”.
A locale in Linux is a collection of environment variables that specify a user’s or system’s language, nationality, character encoding, and other regional characteristics. Language, date and time formats, currency symbols, sorting order (collation), and other program behavior are all controlled by these parameters. The locale settings assist software in displaying data according to the user’s preferences or location. You will come across this error if you messed up while setting up the correct locale for the non-ASCII characters.
How To Fix Error “Locale: Cannot Set LC_ALL to default locale: No such file or directory”
Run the following command to list all system’s currently installed locales in Linux.
locale -a
You will see the output something like below:
LANG=en_US.UTF-8
LC_CTYPE="en_US.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=
Now, It’s time to fix the error. At first, run the following command to export variable to LC_ALL
parameter
$ export LC_ALL="en_US.UTF-8"
Now, run the following command to enable the locales in Linux:
$ sudo locale-gen "en_US.UTF-8"
$ sudo dpkg-reconfigure locales
You can also enable the locales by editing the /etc/default/locale file. You need to set LANG
parameter as below
LANG=en_US.UTF-8
Now at the last, Make sure you have installed glibc-locale package on the system.