W: Setting locale failed

WARNING: Setting locale failed

The 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"

The 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. 1


Alternatively, you can set your locale in ~/.bashrc, 2 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: 3

locale-gen