Fix – perl: warning: Setting locale failed.

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

notion image

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:

notion image

In this utility you need to navigate in the locales by pressing down and after finding your preferred locale; 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 the right arrow to navigate to the -Ok- selection and press enter to select -Ok-.

notion image

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

notion image

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

locale

The output should be like this:

notion image

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

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

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *