W: Setting locale failed

WARNING: Setting locale failed

Last updated
Common Perl warning during upgrades regarding locale settings lies in AcceptEnv directive of SSH config. A better default for any Proxmox VE install, or any Debian-based server in fact.

Error message

If you are getting inexplicable locale warnings when performing upgrades, such as:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_TIME = "en_GB.UTF-8",
	LC_MONETARY = "en_GB.UTF-8",
	LC_ADDRESS = "en_GB.UTF-8",
	LC_TELEPHONE = "en_GB.UTF-8",
	LC_NAME = "en_GB.UTF-8",
	LC_MEASUREMENT = "en_GB.UTF-8",
	LC_IDENTIFICATION = "en_GB.UTF-8",
	LC_NUMERIC = "en_GB.UTF-8",
	LC_PAPER = "en_GB.UTF-8",
	LANG = "en_US.UTF-8"

Likely cause

If you are connected over SSH, consider what locale you are passing over with your client.

This can be seen with e.g. ssh -v root@node as:

debug1: channel 0: setting env LC_ADDRESS = "en_GB.UTF-8"
debug1: channel 0: setting env LC_NAME = "en_GB.UTF-8"
debug1: channel 0: setting env LC_MONETARY = "en_GB.UTF-8"
debug1: channel 0: setting env LANG = "en_US.UTF-8"
debug1: channel 0: setting env LC_PAPER = "en_GB.UTF-8"
debug1: channel 0: setting env LC_IDENTIFICATION = "en_GB.UTF-8"
debug1: channel 0: setting env LC_TELEPHONE = "en_GB.UTF-8"
debug1: channel 0: setting env LC_MEASUREMENT = "en_GB.UTF-8"
debug1: channel 0: setting env LC_TIME = "en_GB.UTF-8"
debug1: channel 0: setting env LC_NUMERIC = "en_GB.UTF-8"

Since PVE is a server, this would be best prevented on the nodes by taking out:

AcceptEnv LANG LC_*

from /etc/ssh/sshd_config.

Alternatively, you can set your locale in ~/.bashrc,   such as:

export LC_ALL=C.UTF-8

Notes

If you actually miss a locale, you can add it with:

dpkg-reconfigure locales

And generate them with:

locale-gen

Manual pages:  locale-gen
Your feedback on the content is welcome in the GitHub Discussions.