Updates from Ricky Lindén

How to fix Debian locale error


I would imagine this happens to non native English speakers from time to time.

You spin up a new Debian server and upon upgrading your server or installing software you get greeted with the following:

apt-listchanges: Can't set locale; make sure $LC_* and $LANG are correct!
Reading changelogs... Done
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "en_GB.UTF-8",
LC_NAME = "fi_FI.UTF-8",
LC_PAPER = "fi_FI.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
locale: Cannot set LC_ALL to default locale: No such file or directory

You need to regenerate your locale(s).

The magic command that fixes your issue

sudo dpkg-reconfigure locales

From there, choose with space your locales that are missing, in my case Finnish and British English. Press enter when done and choose the locale that should be the default, press enter and you should be good to go.


If you still have issues you could try to purge and reinstall locales before reunning the dpkg-reconfigure locales command: sudo apt purge locales && sudo apt install locales