1

This thread is not a duplicate to locale not found/setting locale failed - what should I do? because

  • the file /etc/locale.gen has uncommented the line en_US.UTF-8 UTF-8 which should sufficient
  • no localepurge is installed

I get strange perl: warning: Setting locale failed in all Linux kernel things etc

masi@raspberrypi:~ $ sudo a2enmod rewrite && a2enmod headers && a2enmod ssl
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_PAPER = "en_US.UTF-8",
    LC_ADDRESS = "en_US.UTF-8",
    LC_MONETARY = "en_US.UTF-8",
    LC_NUMERIC = "en_US.UTF-8",
    LC_TELEPHONE = "en_US.UTF-8",
    LC_IDENTIFICATION = "en_US.UTF-8",
    LC_MEASUREMENT = "en_US.UTF-8",
    LC_TIME = "en_US.UTF-8",
    LC_NAME = "en_US.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Module rewrite already enabled

# https://unix.stackexchange.com/a/287622/16920
masi@raspberrypi:~ $ sudo deluser -remove-home pi
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = "en_US.UTF-8",
    LC_PAPER = "fi_FI.UTF-8",
    LC_ADDRESS = "fi_FI.UTF-8",
    LC_MONETARY = "fi_FI.UTF-8",
    LC_NUMERIC = "fi_FI.UTF-8",
    LC_TELEPHONE = "fi_FI.UTF-8",
    LC_IDENTIFICATION = "fi_FI.UTF-8",
    LC_MEASUREMENT = "fi_FI.UTF-8",
    LC_TIME = "fi_FI.UTF-8",
    LC_NAME = "fi_FI.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
/usr/sbin/deluser: The user `pi' does not exist.

Solution

I had en_GB.UTF-8 UTF-8 only enabled in /etc/locale.gen. I should have there only enabled en_US.UTF-8 UTF-8 because of other commands run for it. So I uncommended GB and added US and everything work now

masi@raspberrypi:~ $ sudo vim /etc/locale.gen

masi@raspberrypi:~ $ sudo locale-gen 
Generating locales (this might take a while)...
  en_US.UTF-8... done
Generation complete.

masi@raspberrypi:~ $ sudo a2enmod rewrite && a2enmod headers && a2enmod ssl
Module rewrite already enabled
Module headers already enabled
Considering dependency setenvif for ssl:
Module setenvif already enabled
Considering dependency mime for ssl:
Module mime already enabled
Considering dependency socache_shmcb for ssl:
Module socache_shmcb already enabled
Module ssl already enabled

System: Raspbian Jessie
Hardware: Raspberry Pi 3 b

  • Raspbian is just a rebranded Debian, but /etc/locale.gen shouldn't be empty. Did you select both en_US.UTF-8 and fi_FI.UTF-8 in dpkg-reconfigure locales? – Gilles 'SO- stop being evil' Jun 5 '16 at 21:00
  • 1
    You need to select all the locales that you use. – Gilles 'SO- stop being evil' Jun 5 '16 at 21:04
  • If you're running this on a small embedded system, I'm guessing you don't have a very complete set of language files installed. If en_GB.UTF-8 worked and en_US.UTF-8 failed, I'm going to guess that this is what's happening to you. You'll need to go back and get the language packs you want. And this does look like a dupe of that other question. – Edward Falk Jun 22 '16 at 21:24
  • 1
    @EdwardFalk I found the solution, see the body. It was a human error. I had no en_US enabled in /etc/locale.gen. Those commands suggested in the other thread do NOT throubleshoot this very common human source location. You can have as many locales enabled in the file as you want. I had only one. Mistake was that I thought the commands automatically handle /etc/locale.gen but they do not. In this way, this thread is unique. You should include /etc/locale.gen and check all wanted locales in the troubleshoot strategy. – Léo Léopold Hertz 준영 Jun 22 '16 at 21:26