Upon logging in to a freshly launched Ubuntu 16.04 LTS instance from the Amazon Web Services, I encountered the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
_____________________________________________________________________ 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 _____________________________________________________________________ |
Like what every good Geekysaur would do, the first thing I did was to install the corresponding language pack I need. You could do that by typing in sudo apt-get install language-pack-<language>. Replace <language> with your corresponding language code. So for example, if you wanted to install the English language pack, run sudo apt-get install language-pack-en.
Around the end of the output, you would see something like the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
Generating locales (this might take a while)... en_AG.UTF-8... done en_AU.UTF-8... done en_BW.UTF-8... done en_CA.UTF-8... done en_DK.UTF-8... done en_GB.UTF-8... done en_HK.UTF-8... done en_IE.UTF-8... done en_IN.UTF-8... done en_NG.UTF-8... done en_NZ.UTF-8... done en_PH.UTF-8... done en_SG.UTF-8... done en_ZA.UTF-8... done en_ZM.UTF-8... done en_ZW.UTF-8... done Generation complete. |
Take note of the country code of the language you are trying to update to. For example, if you want to install English – Australia, the code is en_AU.UTF-8.
Now, with this code, modify your environment variables. You can do this by typing in sudo vim /etc/environment. Make sure NOT to remove ANY existing text here (e.g. PATH variables) and just add the following at the end:
1 2 |
LC_ALL=en_AU.UTF-8 LANG=en_AU.UTF-8 |
Of course, make sure to replace the above with the corresponding country level language code you need. Afterwards, all you have to do is run sudo locale-gen "en_AU.UTF-8", again replacing the language code if needed, and you’re done!
Easy right! Did this help you? Do you have an easier way of fixing the locale and language issue mentioned above? We’d love to hear from you so hit us up in the comments or send us a message in our Facebook page!