Libre Software

Ubuntu: resolve the “perl: warning: Setting locale failed” problem

Are you running Ubuntu 14.04 or 16.04 desktop or server edition, and getting warning or errors when installing software via apt-get or aptitiude?

Here is a typical error message:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "es_ES.UTF-8",
LC_MONETARY = "de_DE.UTF-8",
LC_ADDRESS = "de_DE.UTF-8",
LC_TELEPHONE = "de_DE.UTF-8",
LC_NAME = "de_DE.UTF-8",
LC_MEASUREMENT = "de_DE.UTF-8",
LC_IDENTIFICATION = "de_DE.UTF-8",
LC_NUMERIC = "de_DE.UTF-8",
LC_PAPER = "de_DE.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
locale: Cannot set LC_ALL to default locale: No such file or directory

Sometimes, trying to solve the problem using the update-locale or locale commands does not work and generates following error messages:

~ # sudo update-locale
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_PAPER = "de_DE.UTF-8",
LC_ADDRESS = "de_DE.UTF-8",
LC_MONETARY = "de_DE.UTF-8",
LC_NUMERIC = "de_DE.UTF-8",
LC_TELEPHONE = "en_US.UTF-8",
LC_IDENTIFICATION = "en_US.UTF-8",
LC_MEASUREMENT = "en_US.UTF-8",
LC_TIME = "es_ES.UTF-8",
LC_NAME = "de_DE.UTF-8",
LANG = (unset),
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").

or

~ # locale
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=de_DE.UTF-8
LC_TIME=es_ES.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=de_DE.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=de_DE.UTF-8
LC_NAME=de_DE.UTF-8
LC_ADDRESS=de_DE.UTF-8
LC_TELEPHONE=de_DE.UTF-8
LC_MEASUREMENT=de_DE.UTF-8
LC_IDENTIFICATION=de_DE.UTF-8
LC_ALL=

Solution to the perl locale problem

The solution is to export the missing locales to ~/.bash_profile. The following command is a one-command line:

echo "export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8">>~/.bash_profile

You could also run each command separately:

echo "export LANGUAGE=en_US.UTF-8">>~/.bash_profile

Alternatively, edit ~/.bash_profile “by hand” with nano, vim or a graphical editor like gedit or xed (Linux Mint).

Don’t forget to reboot and check if the new locales are applied with the locale command.

Another solution is to add the locale variables to /etc/environment instead of ~/.bash_profile.

  • All
  • Archive
  • Image
  • Linux
  • Linux Server
  • Smartwatches
  • Updated
  • WordPress
AVIF Logo
ImageUpdated

AVIF browser test page: AVIF support in Chrome, Firefox, Edge…

Logo: Alliance for Open Media. License: BSD Last updated on September 29, 2022 Is your browser capable of displaying AVIF images? Here comes a fast answer …

Read More →
LibreOffice installation on Linux
LinuxUpdated

How to install LibreOffice 7.4 on Linux Mint, Ubuntu, MX Linux, Debian…

Last updated on September 27, 2022 This article describes how to install LibreOffice 7.4 on Debian/Ubuntu-based Linux distributions, such as Linux Mint, MX Linux, Ubuntu …

Read More →
How to remove TLSv1.0 and 1.1 and enable TLS 1.3 in Nginx on Ubuntu Server
Linux ServerUpdated

How to remove TLSv1.0 / 1.1 and enable TLS 1.3 in Nginx …

Photo: libre-software.net. License: CC BY-SA 4.0 … on Ubuntu 18.04, 20.04 or 22.04 Last updated on September 29, 2022In January 2020, SSL Labs started to …

Read More →
How to install Mozilla Firefox on Linux (Ubuntu, Linux Mint or any Linux distribution)
LinuxUpdated

How to Install Firefox 105 on Linux Mint, Ubuntu, Debian or any other Linux distribution

Photo: janeb13 / Pixabay, Pixabay License Last updated on September 27, 2022 This how-to explains how to install Firefox on Linux, with or without replacing an existing …

Read More →
Screenshot featuring a chameleon installing Virtual Box on a CentOS computer
Linux

Install VirtualBox on CentOS / RHEL / Scientific Linux

This how-to is about installing VirtualBox on CentOS. Provided instructions should also work on Scientific Linux and Red Hat Enterprise Linux (RHEL). It is possible …

Read More →
DVD support (with libdvdcss) and media codecs on Linux
LinuxUpdated

Install DVD support (libdvdcss) on Debian or Ubuntu

Photo: libre-software.net. License: CC BY-SA 4.0 Last updated on September 27, 2022 On Linux, DVD support is provided through the libdvdcss or libdvdcss2 packages. Some …

Read More →
Automatic Updates in Ubuntu Server
Linux Server

How to set up automatic updates on Ubuntu Server 18.04, 20.04 or 22.04

This guide explains how to configure automatic updates in Ubuntu Server 18.04 “Bionic Beaver”, Ubuntu 20.04 “Focal Fossa” or Ubuntu 22.04 “Jammy Jellyfish” This tutorial …

Read More →
Install Geekbench on Linux (Tutorial)
Linux

How to install Geekbench 4 and Geekbench 5 on Linux

If you want to install and run Geekbench 4 or Geekbench 5 on Linux, follow this tutorial. The following instructions can be used on: a …

Read More →

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.