Fix - perl: warning: Setting locale failed.

November 26, 2021

When you set up your Raspberry Pi, if everything about the locale settings is not gone well you will be seeing an annoying warning for almost every command you run. The warning looks like this:

0

Here is a quick and easy fix for this issue.

sudo dpkg-reconfigure locales

After running this command, the Raspberry Pi OS will start a utility for configuring locales on your system. I will be looking like this:

1

In this utility you need to navigate in the locales by pressing down and after finding the preferred locale of yours; you can select the locale by pressing enter.

In the next screen, the utility will ask you to select the default system locale. Select the one you want and press right arrow to navigate to the selection adn press enter to select .

2

After that, the system will start generating the selected locales.

3

Now the warning must be gone. You can check locale settings with following command.

locale

The output should be like this:

4

To set the locale automatically on boot we need to add the locale set command to the bashrc. You can use following command to add it.

echo 'export LC_CTYPE="en_US.UTF-8"' >> ~/.bashrc

Profile picture

Written by Can Berk Durmus, a computer engineer. He uses OpenCV, CUDA, and QT with Python and C++. He feels comfortable around resource-limited tiny computers and autonomously flying robots.

© 2022