Fix - perl: warning: Setting locale failed.
Jun 15, 2023
Quick and easy fix for annoying warning of Raspberry Pi.
Jul 1, 2023 06:14 PM
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:
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 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-.
After that, the system will start generating the selected locales.
Now the warning must be gone. You can check locale settings with the 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 the following command to add it.
echo 'export LC_CTYPE="en_US.UTF-8"' >> ~/.bashrc