Skip to content

Instantly share code, notes, and snippets.

@justinhartman
Last active August 16, 2020 21:07
Show Gist options
  • Save justinhartman/41e4aa0ae8664087bafdc7843206dd80 to your computer and use it in GitHub Desktop.
Save justinhartman/41e4aa0ae8664087bafdc7843206dd80 to your computer and use it in GitHub Desktop.
Fix perl: warning: Setting locale failed.

How to fix the Perl setting locale failed

This is a massive bug that happens almost every time I install a new server. It's because I use a non-standard US locale so I always get conflicts. This fixes this issue.

Warning Message

The warning message during the installation of Perl applications will appear as follows:

justin:~$ sudo apt install something
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LANG = "en_GB.utf8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

Fix 1: Generating locales

The first option you have it to fix missing locales by generating them with locale-gen:

justin:~$ sudo locale-gen en_GB.UTF-8
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_GB.UTF-8)
Generating locales (this might take a while)...
  en_GB.UTF-8... done
Generation complete.

That's it. You should be OK.

Fix 2: Setting Locale Settings

If Fix 1 didn't work, the locale settings can be set (to en_GB.UTF-8 in the example) as follows:

$ sudo dpkg-reconfigure locales

The dpkg-reconfigure locales command will open a dialog under Debian and Ubuntu for selecting the desired locale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment