In different situations (for example, during the installation of Perl applications, or when I use
apt-get install) I get the following warning message:
perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LC_CTYPE = "UTF-8", LANG = "ru_RU.UTF-8" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C"). 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
This warning message means that you haven’t properly set up locales in your system. To fix this issue you must follow the steps below.
Check the locales
Check which locales you currently have generated by using
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 C C.UTF-8 POSIX ru_RU.utf8
LANG=ru_RU.UTF-8 LANGUAGE= LC_CTYPE="ru_RU.UTF-8" LC_NUMERIC="ru_RU.UTF-8" LC_TIME="ru_RU.UTF-8" LC_COLLATE="ru_RU.UTF-8" LC_MONETARY="ru_RU.UTF-8" LC_MESSAGES="ru_RU.UTF-8" LC_PAPER="ru_RU.UTF-8" LC_NAME="ru_RU.UTF-8" LC_ADDRESS="ru_RU.UTF-8" LC_TELEPHONE="ru_RU.UTF-8" LC_MEASUREMENT="ru_RU.UTF-8" LC_IDENTIFICATION="ru_RU.UTF-8" LC_ALL=
Programmes that support local technology use environment variables to determine the conventions to use for date and time formatting, character display, currency display and codepage selection.
The following environment variables affect locale related behaviour of the system:
- LANG - Determines the default locale in the absence of other locale related environment variables.
- LANGUAGE -
- LC_ADDRESS - Convention used for formatting of street or postal addresses.
- LC_ALL - High precedence override for locale specific behaviour (overrides all other locale variables).
- LC_COLLATE - Collation order.
- LC_CTYPE - Character classification and case conversion.
- LC_MONETARY - Monetary formatting.
- LC_MEASUREMENT - Default measurement system used within the region.
- LC_MESSAGES - Format of interactive words and responses.
- LC_NUMERIC - Numeric formatting.
- LC_PAPER - Default paper size for region.
- LC_RESPONSE - Determines how responses (such as Yes and No) appear in the local language.
- LC_TELEPHONE - Conventions used for representation of telephone numbers.
- LC_TIME - Date and time formats.
To see what locales are supported use:
You will see a long list of the locale names suitable for use in environment variables. In this list, find locale that you need, for example “en”:
Now, you will need to generate this locales. You can do this by using
sudo locale-gen en_US.UTF-8
Generating locales (this might take a while)... en_US.UTF-8... done Generation complete.
Alternatively a locale file can be created manually with
sudo localedef -i en_US -f UTF-8 en_US.UTF-8
This should create the locales and then re-configure them.
Run the command
locale -a to verify the list of available locales (note that the spellings change):
C C.UTF-8 en_US.utf8 POSIX ru_RU.utf8
Verify the new locale:
LANG=en_US.UTF-8 LANGUAGE=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=en_US.UTF-8
To use the new settings with your programmes, re-login (log out and back in) or restart.
If this article helped you solve the problem then please leave a comment
Thanks for reading!