When I run perl
, I get the warning:
perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset
in my case, with debian8.6, i had to change settings in:
/etc/ssh/ssh_config
for #AcceptEnv LANG LC_*
and
sshd_config
for #SendEnv LANG LC_*
then restart ssh service.
at last, did
locale-gen en_US.UTF-8
and dpkg-reconfigure locales
Your OS doesn't know about en_US.UTF-8
.
You didn't mention a specific platform, but I can reproduce your problem:
% uname -a OSF1 hunter2 V5.1 2650 alpha % perl -e exit perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LC_ALL = (unset), LANG = "en_US.UTF-8" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C").
My guess is you used ssh to connect to this older host from a newer desktop machine. It's common for /etc/ssh/sshd_config
to contain
AcceptEnv LANG LC_*
which allows clients to propagate the values of those environment variables into new sessions.
The warning gives you a hint about how to squelch it if you don't require the full-up locale:
% env LANG=C perl -e exit %
or with bash:
$ LANG=C perl -e exit $
For a permanent fix, choose one of
LANG
environment variable in your shell's initialization file.ssh hunter2
, use the command LANG=C ssh hunter2
.SendEnv LANG LC_*
line in the local /etc/ssh/ssh_config
file. (Thanks to this answer. See Bug 1285 for OpenSSH for more.)I experienced this, logging in from one machine to another via ssh
. The remote machine didn’t have the locale files, that I had on my local machine. You can either disable the forwarding of the locale from your local machine to the remote machine (in the file /etc/ssh/sshd_config
remove the line AcceptEnv LANG LC_CTYPE …
) or install the locale (changing it is not necessary in this case).
On Fedora, RHEL, Redhat, CentOS I used
sudo dnf install langpacks-de
for the german (de) language packs. Logged out and in and it worked.
Search for other langpacks with
dnf search langpacks-
To list available locales I used
localectl list-locales
And to set a new one
sudo localectl set-locale de_DE.utf8
If you are creating a rootfs using debootstrap you will need to generate the locales. You can do this by running:
# (optional) enable missing locales
sudo nano /etc/locale.gen
# then regenerate
sudo locale-gen
This tip comes from, https://help.ubuntu.com/community/Xen
Adding the correct locale to ~/.bashrc
, ~/.bash_profile
, /etc/environment
and the like will solve the problem, however it is not recommended, as it overrides the settings from /etc/default/locale
, which is confusing at best and may lead to the locales not being applied consistently at worst.
Instead, one should edit /etc/default/locale
directly, which may look something like this:
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE=en_US
The change will take effect the next time you log in. You can get the new locale in an existing shell by sourcing /etc/default/locale
like this:
$ . /etc/default/locale
Add missing locales to .bash_profile
echo "export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8">>~/.bash_profile
Then source your .bash_profile
source ~/.bash_profile