Just installed Ubuntu, ran apt-get update and apt-get upgrade to encounter a “perl: warning: Setting locale failed.” error?

Run

sudo locale-gen en_US en_US.UTF-8 si_LK si_LK.UTF-8
sudo dpkg-reconfigure locales

“si_LK” should be the locale that the system reports missing. For me, it’s usually “si_LK”.

Missing “si_LK” happens even when I create a DigitalOcean droplet. May be the OS uses my IP’s location to determine which locale to be used? That’s very annoying. Just use “en_US” as we do everywhere else!

Update 1494036470

Add the following line to /etc/environment

LC_ALL="en_US.UTF-8"