Fix - perl: warning: Setting locale failed.

Fix - perl: warning: Setting locale failed.

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:

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:

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 -Ok- selection adn press enter to select -Ok-.

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

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


The output should be like this:

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