Resolved: perl: warning: Please check that your locale settings:

When working with ubuntu, sometimes when you remote ssh into a server you get a bunch of locale errors which are pretty annoying. Fortunately, when using Ubuntu 18 you get a message when you login that is rather helpful:

_____________________________________________________________________
WARNING! Your environment specifies an invalid locale.
The unknown environment variables are:
LC_CTYPE=UTF-8 LC_ALL=
This can affect your user experience significantly, including the
ability to manage packages. You may install the locales by running:

sudo apt-get install language-pack-UTF-8
or
sudo locale-gen UTF-8

To see all available language packs, run:
apt-cache search "^language-pack-[a-z][a-z]$"
To disable this message for all users, run:
sudo touch /var/lib/cloud/instance/locale-check.skip
_____________________________________________________________________

so, the key here is that your client machine has a locale that your ubuntu server is struggling to grasp. Sadly, you follow the instructions just to run across this:

$ sudo apt-get install language-pack-UTF-8
[sudo] password for : 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package language-pack-UTF-8

or this

$ sudo locale-gen UTF-8
Error: 'UTF-8' is not a supported language or locale

or this

perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = "en_US.UTF-8",
LC_CTYPE = "en_US.UTF-8",
LANG = "en_US.UTF-8"
    are supported and installed on your system.

which makes you wonder… if they don’t work why did I say the message was rather helpful? Well, because it points us in the right direction: We need to install the language pack somehow. Well, it turns out I am using a Mac and it is in spanish, so Ubuntu is unable to translate that into one of its locales. So, take the example below:

export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
sudo dpkg-reconfigure locales

This will tell it to default to en_us and call it a day. In my case, I ran in order to get the language code for Spanish/Mexico which is: es_MX.UTF-8. Make sure you install the language while you are at it on the dpkg-reconfigure locales screen before you try to run the following commands. That means you can look yours up if you are using a different language and plug it in like so:

export LC_ALL="es_MX.UTF-8"
export LC_CTYPE="es_MX.UTF-8"
sudo dpkg-reconfigure locales

and you should be golden now!

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: