Falling back to the standard locale – Solution

If you are trying to use the perl command in your terminal or execute a script coded in the language, you may encounter the Falling back to the standard locale error. This indicates that your Linux system is missing a particular software package that Perl relies on, or the software has become corrupted or misconfigured. In this tutorial, we will show you how to remedy the error and get your perl command working again.

In this tutorial you will learn:

  • How to fix the Falling back to the standard locale error message on all major Linux distros
perl: warning: Falling back to the standard locale error message on Linux
perl: warning: Falling back to the standard locale error message on Linux
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software perl, locales
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Falling back to the standard locale – Solution




The error occurs when trying to execute a Perl script or just using the perl command in terminal. It looks like this:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

The problem is that your system’s locale is not set. You may be missing the software entirely or just have not configured the locale. This message may appear for example when you are installing new packages into your Linux system. Fortunately, there is an easy fix to this problem.

Depending on which Linux distro you are using, follow the appropriate set of instructions below to remedy this error.

Debian-based and Ubuntu solution

For systems based on Debian Linux, including Ubuntu.

  1. First make sure that you have the locales package installed:
    $ sudo apt update
    $ sudo apt install locales
    

    The previous command will install locales package or it will output that locales is already installed.

  2. Next, use the dpkg-reconfigure command to configure the locales package.
    $ sudo dpkg-reconfigure locales
    
  3. Use the menu that shows up to reconfigure your locales. For example, en_US.UTF-8 UTF-8 for English speaking Americans. Pick the appropriate one for you.
    Configuring the locale on Ubuntu
    Configuring the locale on Ubuntu

RHEL-based and Fedora Solution

For systems based on Red Hat, including Fedora, CentOS, and AlmaLinux.



  1. First, search for the appropriate language pack inside of the official software repositories:
    $ dnf search langpacks-
    
  2. Once you find the right one, install it with dnf. For example, English speakers would need langpacks-en.
    $ sudo dnf install langpacks-en
    
  3. Next, use the following command to list all of the locales available on your system.
    $ localectl list-locales
    
  4. Once you have identified the proper one for your system, set your locale with the localectl set-locale command. In our case, we will set our locale to en_US.UTF-8.
    $ sudo localectl set-locale en_US.UTF-8
    

Arch Linux based and Manjaro

For systems based on Arch Linux, including Manjaro.

  1. Open the /etc/locale.gen in nano or your favorite text editor.
    $ sudo nano /etc/locale.gen
    
  2. Uncomment the locale that you wish to use on your system, and make sure others are commented out if you do not plan to use them. Save the changes when you are done with your edits
    Setting the locale on Manjaro
    Setting the locale on Manjaro
  3. For these changes to take effect, run the locale-gen command.
    $ sudo locale-gen
    

Closing Thoughts




In this tutorial, we saw how to resolve the perl: warning: Falling back to the standard locale error message on a Linux system. Having your locale misconfigured or unset on Linux will cause problems with Perl, which may manifest as errors during package installation and other ordinary terminal tasks. The instructions here cover all major Linux distros, so you can get Perl working again regardless of what type of Linux system you are running.



Comments and Discussions
Linux Forum