Setting locale was not correct - missing package libencode-locale-perl was the root cause

Problem occured during upgrading after new set up dietpi system:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_TIME = "de_DE.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_GB.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_GB.UTF-8").

Tried to solve it by either

$ dietpi-config 
$ locale-gen "en_DE.UTF-8"
$ dpkg-reconfigure locales

What solves was installing the missing package

$ apt install libencode-locale-perl

Problem was gone!

Many thanks for reporting.

On which hardware/image did you face this? And did you try it on local console, SSH or serial console?

And did you test whether a reboot applies the locale change without having the package installed?

Thanks Micha!

I work on Pi 4b 2gb
I work via ssh in 99% of the cases
I set up with en.us-utf8 and German keyboard.
I did not remember whether I rebooted, but I guess not.

Do you use OpenSSH, and if so, can you show:

grep -r AcceptEnv /etc/ssh

It can allow the SSH client to pass a locale which may not be available at the server, throwing such errors then. But AFAIK we disable it :thinking:.

I am currently running into the same issue on my Raspberry Pi 2b

I tried all the commands from the first post and even installing lib encode-locale-perldidn’t do the trick.

❯ sudo apt install libencode-locale-perl
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  libencode-locale-perl
0 upgraded, 1 newly installed, 0 to remove and 40 not upgraded.
Need to get 12.9 kB of archives.
After this operation, 33.8 kB of additional disk space will be used.
Get:1 https://deb.debian.org/debian bookworm/main armhf libencode-locale-perl all 1.05-3 [12.9 kB]
Fetched 12.9 kB in 0s (27.7 kB/s)
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_CTYPE = "en_US.UTF-8",
	LANG = "de_DE.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("de_DE.UTF-8").
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libencode-locale-perl.
(Reading database ... 35139 files and directories currently installed.)
Preparing to unpack .../libencode-locale-perl_1.05-3_all.deb ...
Unpacking libencode-locale-perl (1.05-3) ...
Setting up libencode-locale-perl (1.05-3) ...