Introduction
Last week I ordered a new Virtual Private Server at Webtropia.com and tried to install a few tools like the well known htop. During the installation process the following error occured.
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "de_DE.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_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Selecting previously unselected package htop.
(Reading database ... 22512 files and directories currently installed.)
Unpacking htop (from .../htop_1.0.1-1_amd64.deb) ...
Processing triggers for man-db ...
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
The error occurs because the Ubuntu 12.04 LTS image had no default language set or the language files were simply missing.
I have found a fix for this problem in the Ubuntu forums.
You can always check the locales by calling “locales” on the command line:
root@222017:~# locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=de_DE.UTF-8
LANGUAGE=
LC_CTYPE="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_MESSAGES="de_DE.UTF-8"
LC_PAPER="de_DE.UTF-8"
LC_NAME="de_DE.UTF-8"
LC_ADDRESS="de_DE.UTF-8"
LC_TELEPHONE="de_DE.UTF-8"
LC_MEASUREMENT="de_DE.UTF-8"
LC_IDENTIFICATION="de_DE.UTF-8"
LC_ALL=
As you can see I would also have to set the “de_DE.UTF-8” language package as my default for “LANGUAGE” and for “LC_ALL”. You would need to replace the package name with the language you would like to set or which is already set in the variable “LANG”.
sudo locale-gen de_DE.UTF-8
Result:
root@222017:~# locale-gen de_DE.UTF-8
Generating locales...
de_DE.UTF-8... done
Generation complete.
After that we have to reconfigure the locales again by running:
sudo dpkg-reconfigure locales
Result:
root@222017:~# dpkg-reconfigure locales
Generating locales...
de_DE.UTF-8... up-to-date
Generation complete.
After this fix you will not receive any annoying errors regarding unset languages. Note: This fix is for Ubuntu 12.04 LTS Server.