Quick Tutorial: How to Fix “Setting locale failed” Issue on Ubuntu

In case you’re running Ubuntu 18.04 ( or earlier versions as well, such as 16.04, 14.04 ), you may be encountering a locales warning or error while trying to update your package index or installing a package.

As the locales package configuration states:

Locales are a framework to switch between multiple languages and allow users to use their language, country, characters, collation order, etc.

The error looks something like this:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_MONETARY = "de_DE.UTF-8",
	LC_ADDRESS = "de_DE.UTF-8",
	LC_TELEPHONE = "de_DE.UTF-8",
	LC_NAME = "de_DE.UTF-8",
	LC_MEASUREMENT = "de_DE.UTF-8",
	LC_IDENTIFICATION = "de_DE.UTF-8",
	LC_NUMERIC = "de_DE.UTF-8",
	LC_PAPER = "de_DE.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 may encounter this error very often on a fresh install of Ubuntu or Debian.

One solution to fix this issue, first run the locale command to list the locales currently defined for your user account.

$ locale

The output will look something like this:

LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="de_DE.UTF-8"
LC_NUMERIC=de_DE.UTF-8
LC_TIME="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_MONETARY=de_DE.UTF-8
LC_MESSAGES="de_DE.UTF-8"
LC_PAPER=de_DE.UTF-8
LC_NAME=de_DE.UTF-8
LC_ADDRESS=de_DE.UTF-8
LC_TELEPHONE=de_DE.UTF-8
LC_MEASUREMENT=de_DE.UTF-8
LC_IDENTIFICATION=de_DE.UTF-8
LC_ALL=

To generate the missing locale and reconfigure locales, identify the name of your locale ( in my case de_DE.UTF-8), or use one another one that you prefer, such as en_US.UTF-8.

Then generate it using the following command:

$ sudo locale-gen "de_US.UTF-8"

And you’ll get the output:

Generating locales (this might take a while)...
  de_DE.UTF-8... done
Generation complete.

After which, reconfigure locales using the following command:

$ sudo dpkg-reconfigure locales

And you’ll receive the output:

Generating locales...
  de_DE.UTF-8... up-to-date
Generation complete.

And now you shouldn’t receive any more errors!

If you’ve encountered any issues with this short tutorial, please feel free to let us know in the comments or by contacting us via our social media channels, and we’ll get back to you as soon as possible.

Get a High RAM VPS at Entry-level Pricing

Starting with 2GB RAM at $6.99/month

Take your pick from our KVM VPS that offer a generous amount of RAM at an affordable price. We've got 5 plans for you to choose from, our cheapest featuring 2GB RAM at $6.99/mo.

[Main Features] - SSD Drives - KVM Virtualization - 1Gbps Shared Uplink - Location: Chicago, IL

Pick one of our KVM plans

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments