Perl: warning: Setting locale failed locale settings

Hi my os version is:

# cat /etc/os-release 
NAME="AlmaLinux"
VERSION="8.10 (Cerulean Leopard)"
ID="almalinux"
ID_LIKE="rhel centos fedora"
VERSION_ID="8.10"
PLATFORM_ID="platform:el8"
PRETTY_NAME="AlmaLinux 8.10 (Cerulean Leopard)"
ANSI_COLOR="0;34"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:almalinux:almalinux:8::baseos"
HOME_URL="https://almalinux.org/"
DOCUMENTATION_URL="https://wiki.almalinux.org/"
BUG_REPORT_URL="https://bugs.almalinux.org/"

ALMALINUX_MANTISBT_PROJECT="AlmaLinux-8"
ALMALINUX_MANTISBT_PROJECT_VERSION="8.10"
REDHAT_SUPPORT_PRODUCT="AlmaLinux"
REDHAT_SUPPORT_PRODUCT_VERSION="8.10"
SUPPORT_END=2029-06-01

I did this steps:

sudo dnf install glibc-langpack-en
sudo vi /etc/locale.conf

and put this:

LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8

and put there’s:

~/.bashrc
~/.bash_profile
/etc/profile.d/locale.sh

Also output of locale command is:

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

but when I ssh to the server or logging to root user via su I get this damn error:

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

Did you get this resolved? I was able to reproduce this on my 8.10 server, but I’m at the edge of my technical knowledge for sure. There are a LOT of ideas on this stack overflow thread that might help. Before suggesting any of them, I thought I’d ask: did you attempt any of the things there, or anything else?

Hi, I did this solution, and whatever I found from Google and stack overflow.
it’s my sshd config:

...
# Accept locale-related environment variables
AcceptEnv LANG LC_*
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS
...

also when I want to ssh I put this in my ssh command:

LANG=C LC_ALL=C ssh <server ip> -l mrg -p <server port>

but when I login I got this:
Activate the web console with: systemctl enable --now cockpit.socket

Last login: Mon Jun 10 11:10:38 2024 from 5.219.145.76
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = "en_US",
	LC_ALL = (unset),
	LC_MEASUREMENT = "az_IR",
	LC_PAPER = "az_IR",
	LC_MONETARY = "az_IR",
	LC_NAME = "az_IR",
	LC_ADDRESS = "az_IR",
	LC_NUMERIC = "az_IR",
	LC_TELEPHONE = "az_IR",
	LC_IDENTIFICATION = "az_IR",
	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 = "en_US",
	LC_ALL = (unset),
	LC_MEASUREMENT = "az_IR",
	LC_PAPER = "az_IR",
	LC_MONETARY = "az_IR",
	LC_NAME = "az_IR",
	LC_ADDRESS = "az_IR",
	LC_NUMERIC = "az_IR",
	LC_TELEPHONE = "az_IR",
	LC_IDENTIFICATION = "az_IR",
	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 = "en_US",
	LC_ALL = (unset),
	LC_MEASUREMENT = "az_IR",
	LC_PAPER = "az_IR",
	LC_MONETARY = "az_IR",
	LC_NAME = "az_IR",
	LC_ADDRESS = "az_IR",
	LC_NUMERIC = "az_IR",
	LC_TELEPHONE = "az_IR",
	LC_IDENTIFICATION = "az_IR",
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").

Another thing. when I logged in with my user then I wanted to switch to the root user I got this again. and it’s not related to ssh login. I switch to another account in my server terminal:

[mrg@myServer ~]$ su
Password: 
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = "en_US",
	LC_ALL = (unset),
	LC_MEASUREMENT = "az_IR",
	LC_PAPER = "az_IR",
	LC_MONETARY = "az_IR",
	LC_NAME = "az_IR",
	LC_ADDRESS = "az_IR",
	LC_NUMERIC = "az_IR",
	LC_TELEPHONE = "az_IR",
	LC_IDENTIFICATION = "az_IR",
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
[root@myServer mrg]#

You have this Alma machine, and when you log into locally as regular user, you seem to have “ok” locale.
If you log in as root to local text console (not GUI), what do you get?

If you have logged in locally as regular user and then run su -, you get the error?

The machine that you do use for ssh, what OS and locale does it have?
Do both ssh to regular user and ssh to root behave the same?


For comparison, I did use en_US as the language in Alma installer, and:

$ localectl
   System Locale: LANG=en_US.UTF-8
       VC Keymap: fi-winkeys
      X11 Layout: fi
     X11 Variant: winkeys
$ cat /etc/locale.conf
LANG="en_US.UTF-8"
$ sudo dnf history list glibc-langpack-en | tail -1
     1 |                                                                   | 2019-12-16 17:55 | Install        |  710 >E
$ rpm -qa glibc-lang\*
glibc-langpack-en-2.28-236.el8_9.12.x86_64

The glibc-langpack-en was installed by installer and no other glibc-langpack*
(I did change the keyboard layout in the installer.)


Alma 8 does not provide /etc/profile.d/locale.sh

$ dnf -q provides /etc/profile.d/locale.sh
Error: No Matches found

If do you set environment there … by default that should not be necessary.

No it’s not ok when i login vis ssh to regular user from my Linux Mint:

mrg@danial-HP:~$ LANG=C LC_ALL=C ssh <my alma linux server ip> -l mrg -p <my alma linux ssh port>
mrg@<my alma linux server ip>'s password: 
Activate the web console with: systemctl enable --now cockpit.socket

Last login: Mon Jun 10 11:13:59 2024 from 5.219.145.76
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = "en_US",
	LC_ALL = (unset),
	LC_MEASUREMENT = "az_IR",
	LC_PAPER = "az_IR",
	LC_MONETARY = "az_IR",
	LC_NAME = "az_IR",
	LC_ADDRESS = "az_IR",
	LC_NUMERIC = "az_IR",
	LC_TELEPHONE = "az_IR",
	LC_IDENTIFICATION = "az_IR",
	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 = "en_US",
	LC_ALL = (unset),
	LC_MEASUREMENT = "az_IR",
	LC_PAPER = "az_IR",
	LC_MONETARY = "az_IR",
	LC_NAME = "az_IR",
	LC_ADDRESS = "az_IR",
	LC_NUMERIC = "az_IR",
	LC_TELEPHONE = "az_IR",
	LC_IDENTIFICATION = "az_IR",
	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 = "en_US",
	LC_ALL = (unset),
	LC_MEASUREMENT = "az_IR",
	LC_PAPER = "az_IR",
	LC_MONETARY = "az_IR",
	LC_NAME = "az_IR",
	LC_ADDRESS = "az_IR",
	LC_NUMERIC = "az_IR",
	LC_TELEPHONE = "az_IR",
	LC_IDENTIFICATION = "az_IR",
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").

Now I log in root user (with text console) I don’t have any desktop on my alma Linux server . I log in from SSH regular user then with su command go to the root user on text terminal:

[mrg@almaServer ~]$ su
Password: 
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = "en_US",
	LC_ALL = (unset),
	LC_MEASUREMENT = "az_IR",
	LC_PAPER = "az_IR",
	LC_MONETARY = "az_IR",
	LC_NAME = "az_IR",
	LC_ADDRESS = "az_IR",
	LC_NUMERIC = "az_IR",
	LC_TELEPHONE = "az_IR",
	LC_IDENTIFICATION = "az_IR",
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").

and I run the commands you give:

[root@almaServer mrg]# localectl
   System Locale: LANG=en_US.UTF-8
       VC Keymap: us
      X11 Layout: us
[root@almaServer mrg]# cat /etc/locale.conf
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8
[root@almaServer mrg]# sudo dnf history list glibc-langpack-en | tail -1
    21 | update                                                                                                    | 2024-06-08 18:17 | I, U           |  336 EE
[root@almaServer mrg]# rpm -qa glibc-lang\*
glibc-langpack-en-2.28-251.el8_10.2.x86_64
[root@almaServer mrg]#