44

Perl: warning: Setting locale failed in Debian and Ubuntu

 6 years ago
source link: https://www.tuicool.com/articles/hit/2eAbuib
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

7jYRVbi.gif

I am trying to install package and doing some other work. But, getting the error that read as “ perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: ” How do I fix this problem on my Debian Linux server?

The warning message displayed when Perl based applications called. For example, apt/apt-get internally use Perl to do management of packages in Debian or Ubuntu Linux.

Perl: warning: Setting locale failed in Debian and Ubuntu

Here is a sample session created byapt-get command /apt command:

$ sudo apt-get install iperf

Sample outputs:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  iperf
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/57.2 kB of archives.
After this operation, 164 kB of additional disk space will be used.
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_TIME = "en_IN.UTF-8",
	LC_MONETARY = "en_IN.UTF-8",
	LC_MEASUREMENT = "en_IN.UTF-8",
	LC_NUMERIC = "en_IN.UTF-8",
	LC_PAPER = "en_IN.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
Selecting previously unselected package iperf.
(Reading database ... 40493 files and directories currently installed.)
Preparing to unpack .../iperf_2.0.9+dfsg1-1_amd64.deb ...
Unpacking iperf (2.0.9+dfsg1-1) ...
Setting up iperf (2.0.9+dfsg1-1) ...
Processing triggers for man-db (2.7.6.1-2) ...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_TIME = "en_IN.UTF-8",
	LC_MONETARY = "en_IN.UTF-8",
	LC_MEASUREMENT = "en_IN.UTF-8",
	LC_NUMERIC = "en_IN.UTF-8",
	LC_PAPER = "en_IN.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").
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_TIME = "en_IN.UTF-8",
	LC_MONETARY = "en_IN.UTF-8",
	LC_MEASUREMENT = "en_IN.UTF-8",
	LC_NUMERIC = "en_IN.UTF-8",
	LC_PAPER = "en_IN.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
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_TIME = "en_IN.UTF-8",
	LC_MONETARY = "en_IN.UTF-8",
	LC_MEASUREMENT = "en_IN.UTF-8",
	LC_NUMERIC = "en_IN.UTF-8",
	LC_PAPER = "en_IN.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").

Understanding locales in Ubuntu and Debian Linux

Locales are a framework to switch between multiple languages and allow users to use their language, country, characters, collation order, date and time, etc. Make sure you set locales generating UTF-8 locales. Other character sets can be set for backwards compatibility with older systems and software.

How to fix Perl: warning: Setting locale failed in Debian and Ubuntu

Type the following commands to fix it. I am using en_US.UTF-8. You can see list of all localisation in /etc/locale.gen using thecat command:

cat /etc/locale.gen

OR

more /etc/locale.gen

Another option is to usegrep command to search for specific locales.

## For example, search for English India ##
grep en_IN /etc/locale.gen
 
## Search for English US ##
grep en_US /etc/locale.gen
 
## Search for Japanese ##
grep ja_JP /etc/locale.gen

AzyYjy3.png!web

Understanding “ja_JP.UTF-8” or “en_US.UTF-8”

The ja_JP.UTF-8 defined character encoding for Japanese language users as follows:

  1. Locale is ja_JP
  2. Encoding is UTF-8

Similarly, en_US.UTF-8 is for English user from USA:

  1. So locale is set to en_US
  2. And encoding is set to UTF-8

To view current information about the current locale, or all locales, on your screen run locale command:

locale

Sample outputs:

LANG=en_IN.UTF-8
LC_CTYPE="en_IN.UTF-8"
LC_NUMERIC=en_IN.UTF-8
LC_TIME=en_IN.UTF-8
LC_COLLATE="en_IN.UTF-8"
LC_MONETARY=en_IN.UTF-8
LC_MESSAGES="en_IN.UTF-8"
LC_PAPER=en_IN.UTF-8
LC_NAME="en_IN.UTF-8"
LC_ADDRESS="en_IN.UTF-8"
LC_TELEPHONE="en_IN.UTF-8"
LC_MEASUREMENT=en_IN.UTF-8
LC_IDENTIFICATION="en_IN.UTF-8"
LC_ALL=

How to generate locales on Debian or Ubuntu Linux

Run the locale-gen command to generate locales from /etc/locale.gen for English USA user:

$ sudo locale-gen

OR

$ sudo locale-gen en_US.UTF-8

One can run the following too:

$ sudo localedef -i en_US -f UTF-8 en_US.UTF-8

How to fix a locale setting warning from Perl in Debian and Ubuntu Linux

Personally, I fixed it as follows using combination of the export command, locale-gen command and [nixmd name=”dpkg-reconfigure”]:

$ sudo export LANGUAGE=en_US.UTF-8
 $ sudo export LANG=en_US.UTF-8
 $ sudo export LC_ALL=en_US.UTF-8
 $ sudo locale-gen en_US.UTF-8

Sample outputs:

Generating locales (this might take a while)...
  en_US.UTF-8... done
Generation complete.

Open the dialog box:

$ sudo dpkg-reconfigure locales
V7VfmiZ.png!web

Next, set defaults to fix a locale setting warning from Perl:

UvURBry.png!web

Now you set up correct locales and test with apt/apt-get:

$ sudo apt install foo

Conclusion

This page showed you how to use the dpkg-reconfigure and other commands to set up the desired locale. Setting up correct locales is essential. Hence, you ran into the problem, and we configured the locales in Debian or Ubuntu to fix it. For more information see this and this page about locale encodings.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK