How to fix a locale setting warning from Perl
On my ODROID-C1 running Ubuntu the issue was indeed the ~/.pam_environment file. Some of the variables were es_US.UTF-8 instead of en_US.UTF-8. Thank you.
48 Answers 48
Here is how to solve it on Mac OS X v10.7 (Lion) or Cygwin (Windows 10):
Add the following lines to your bashrc or bash_profile file on the host machine:
# Setting for the new UTF-8 terminal support in Lion export LC_CTYPE=en_US.UTF-8 export LC_ALL=en_US.UTF-8
If you are using Z shell (zsh), edit file zshrc:
# Setting for the new UTF-8 terminal support in Lion LC_CTYPE=en_US.UTF-8 LC_ALL=en_US.UTF-8
Thanks, I’ve search a solution for this problem for a long time, and I always thought it’s a problem in my Ubuntu server configuration, and it seemed that there was no solution that helped (all that dkpg-reconfigure stuff(
Because LC_ALL overwrites all other variables, I’d rather set LANG=de_AT.UTF-8 and individual variables like LC_MESSAGES=en_US.UTF-8 . If a variable is not set it falls back to LANG . You can also eg. unset LC_CTYPE to force it fall back to LANG .
Putting these lines in ~/.bashrc solved it for me. then must reload using source ~/.bashrc . Thnks
Thanks, this worked fine on ZSH and the oh-my-zsh plugin under Mac OS X El Capitan, at the bottom of ~/.zshrc : LC_CTYPE=en_US.UTF-8 LC_ALL=en_US.UTF-8
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
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:
For a permanent fix, choose one of
- On the older host, set the LANG environment variable in your shell’s initialization file.
- Modify your environment on the client side, e.g., rather than ssh hunter2 , use the command LANG=C ssh hunter2 .
- If you have administrator rights, stop ssh from sending the environment variables by commenting out the SendEnv LANG LC_* line in the local /etc/ssh/ssh_config file. (Thanks to this answer. See Bug 1285 for OpenSSH for more.)
Thanks! I had this error message when connecting with git to my server. After adding de_CH.UTF-8 (was not supported there but used locally) with dpkg-reconfigure locales the message is gone.
I had this issue for ages. removing «AcceptEnv LANG LC_*» from sshd_config finally resolved it. Thanks for the hint!
@Greg Bacon, Wouldn’t there also be cases in which you would want to set the environment variables system wide, for example by creating an /etc/environment file? help.ubuntu.com/community/…
@HermannIngjaldsson, at least on Ubuntu (12.10), there was no need to reboot the server (after removing «AcceptEnv LANG LC_*»). I just reloaded ssh config: service ssh reload , which takes a fraction of a second, and doesn’t even cause the current ssh session to terminate.
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
locale-gen does not take any arguments (in Debian stable at least). Instead, edit /etc/locale.gen to uncomment the locales you want, then run sudo locale-gen
some distributions don’t use a configuration file and need the following, sudo locale-gen en_US.UTF-8
export LANGUAGE=en_US.UTF-8 export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8 export LC_CTYPE=en_US.UTF-8
It works for Debian. I don’t know why — but locale-gen had not results.
Important! It’s a temporary solution. It has to be run for each session.
Worked for me too. I only had to set the two settings (LANGUAGE and LC_ALL) that appeared unset in the Perl warnings
On Debian, local-gen only processes locales that are uncommented in /etc/local.gen . You may need to do echo en_US UTF-8 >> /etc/locale.gen first.
This generally means you haven’t properly set up locales on your Linux box.
On Debian or Ubuntu, that means you need to do
$ sudo locale-gen $ sudo dpkg-reconfigure locales
dpkg-reconfigure locales fails itself with the same perl locale error messages that one is trying to fix in the first place.
This worked for me in Ubuntu 14.04, although I had to add the missing locale first with sudo locale-gen es_UY.UTF-8
For macOS & Mac OS X users only
I was getting the same warning while using Git
To resolve this warning Uncheck the Set locale environment variable on startup option and restart your terminal. Below screen shot represents my terminal settings.
I tried all the others but this one did it for me. I use iTerm and it has the same character encoding option.
This totally does the trick for Mac OS. By the way, this starting happening to me right after upgraded to macOS Sierra. And this did fix this issue for me.
this fixed my problem. it started to happen to me, after updating to Mac OS X High Sierra from Sierra.
Yup. I use iTerm. Wiping problem Mac system settings fixed some Mac crashes, but caused this issue when running Perl on my long-stable CentOS server, connected via Mac / iTerm. Disabling the automatic locale set on connect fixed it. iTerm -> Preferences ->Profiles->Terminal->Environment->Set locale variables automatically. Uncheck this, and restart iTerm.
It is simple fix in Ubuntu. You have to generate the Locales from scratch, running the following commands from the command line:
sudo locale-gen en_US en_US.UTF-8 sudo dpkg-reconfigure locales
This should create the locales and then re-configure them.
Adding the following to /etc/environment fixed the problem for me on Debian and Ubuntu (of course, modify to match the locale you want to use):
LANGUAGE=en_US.UTF-8 LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8
.. I got a warning saying setting locale in /etc/environment is deprecated and should instead be set in /etc/default/locale . Both seems to work for now.
$ cat /etc/environment . LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
Then log out of SSH session and log in again.
$ locale locale: Cannot set LC_ALL to default locale: No such file or directory LANG=en_US.UTF-8 LANGUAGE= LC_CTYPE=en_US.UTF-8 LC_NUMERIC=ru_RU.UTF-8 LC_TIME=ru_RU.UTF-8 LC_COLLATE="en_US.UTF-8" LC_MONETARY=ru_RU.UTF-8 LC_MESSAGES="en_US.UTF-8" LC_PAPER=ru_RU.UTF-8 LC_NAME=ru_RU.UTF-8 LC_ADDRESS=ru_RU.UTF-8 LC_TELEPHONE=ru_RU.UTF-8 LC_MEASUREMENT=ru_RU.UTF-8 LC_IDENTIFICATION=ru_RU.UTF-8 LC_ALL= $ sudo su # export LANGUAGE=en_US.UTF-8 # export LANG=en_US.UTF-8 # export LC_ALL=en_US.UTF-8 # locale-gen en_US.UTF-8 Generating locales. en_US.UTF-8. up-to-date Generation complete. # dpkg-reconfigure locales Generating locales. en_AG.UTF-8. done en_AU.UTF-8. done en_BW.UTF-8. done en_CA.UTF-8. done en_DK.UTF-8. done en_GB.UTF-8. done en_HK.UTF-8. done en_IE.UTF-8. done en_IN.UTF-8. done en_NG.UTF-8. done en_NZ.UTF-8. done en_PH.UTF-8. done en_SG.UTF-8. done en_US.UTF-8. up-to-date en_ZA.UTF-8. done en_ZM.UTF-8. done en_ZW.UTF-8. done Generation complete. # exit $ locale LANG=en_US.UTF-8 LANGUAGE=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
🛠️ Исправляем ошибку perl: warning: Setting locale failed
Мануал
./nikto.pl -h $IPADDRESS perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LC_CTYPE = "UTF-8", LANG = "en_US.UTF-8" are supported and installed on your system. perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
Решение
Экспортируйте следующую локаль в своем терминале
export LC_CTYPE=en_US.UTF-8 export LC_ALL=en_US.UTF-8
Это хорошо, если вам нужно сделать один раз.
Однако, если вам нужно запускать его периодически, вы можете установить его в профиле, чтобы он загружался при входе в систему.
- Перейти в домашний каталог пользователя
- Измените .bash_profile (если вы используете bash), используя vi
- Добавьте следующее содержание и сохраните файл
export LC_CTYPE=en_US.UTF-8 export LC_ALL=en_US.UTF-8
Пожалуйста, не спамьте и никого не оскорбляйте. Это поле для комментариев, а не спамбокс. Рекламные ссылки не индексируются!
- Аудит ИБ (49)
- Вакансии (12)
- Закрытие уязвимостей (105)
- Книги (27)
- Мануал (2 306)
- Медиа (66)
- Мероприятия (39)
- Мошенники (23)
- Обзоры (820)
- Обход запретов (34)
- Опросы (3)
- Скрипты (114)
- Статьи (352)
- Философия (114)
- Юмор (18)
Anything in here will be replaced on browsers that support the canvas element
OpenVPN Community Edition (CE) – это проект виртуальной частной сети (VPN) с открытым исходным кодом. Он создает защищенные соединения через Интернет с помощью собственного протокола безопасности, использующего протокол SSL/TLS. Этот поддерживаемый сообществом проект OSS (Open Source Software), использующий лицензию GPL, поддерживается многими разработчиками и соавторами OpenVPN Inc. и расширенным сообществом OpenVPN. CE является бесплатным для […]
Что такое 404 Frame? Большинство инструментов для взлома веб-сайта находятся в 404 Frame. Итак, что же представляют собой команды? Вы можете отдавать команды, используя повседневный разговорный язык, поскольку разработчики не хотели выбирать очень сложную систему команд. Команды Команды “help” / “commands” показывают все команды и их назначение. Команда “set target” – это команда, которая должна […]
В этой заметке вы узнаете о блокировке IP-адресов в Nginx. Это позволяет контролировать доступ к серверу. Nginx является одним из лучших веб-сервисов на сегодняшний день. Скорость обработки запросов делает его очень популярным среди системных администраторов. Кроме того, он обладает завидной гибкостью, что позволяет использовать его во многих ситуациях. Наступает момент, когда необходимо ограничить доступ к […]
Знаете ли вы, что выполняется в ваших контейнерах? Проведите аудит своих образов, чтобы исключить пакеты, которые делают вас уязвимыми для эксплуатации Насколько хорошо вы знаете базовые образы контейнеров, в которых работают ваши службы и инструменты? Этот вопрос часто игнорируется, поскольку мы очень доверяем им. Однако для обеспечения безопасности рабочих нагрузок и базовой инфраструктуры необходимо ответить […]
Одной из важнейших задач администратора является обеспечение обновления системы и всех доступных пакетов до последних версий. Даже после добавления нод в кластер Kubernetes нам все равно необходимо управлять обновлениями. В большинстве случаев после получения обновлений (например, обновлений ядра, системного обслуживания или аппаратных изменений) необходимо перезагрузить хост, чтобы изменения были применены. Для Kubernetes это может быть […]
Locale variables have no effect in remote shell (perl: warning: Setting locale failed.)
~$ ssh example.com sudo aptitude upgrade . Traceback (most recent call last): File "/usr/bin/apt-listchanges", line 33, in from ALChacks import * File "/usr/share/apt-listchanges/ALChacks.py", line 32, in sys.stderr.write(_("Can't set locale; make sure $LC_* and $LANG are correct!\n")) NameError: name '_' is not defined 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_US.UTF-8" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C"). locale: Cannot set LC_ALL to default locale: No such file or directory No packages will be installed, upgraded, or removed. 0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Need to get 0 B of archives. After unpacking 0 B will be used. .
I don’t have this problem when i connect from an older ubuntu installation. This is output from my ubuntu 12.04 installation, LANG and LANGUAGE are set
$ locale LANG=de_DE.UTF-8 LANGUAGE=de_DE:en_GB:en LC_CTYPE="de_DE.UTF-8" LC_NUMERIC=de_DE.UTF-8 LC_TIME=de_DE.UTF-8 LC_COLLATE="de_DE.UTF-8" LC_MONETARY=de_DE.UTF-8 LC_MESSAGES="de_DE.UTF-8" LC_PAPER=de_DE.UTF-8 LC_NAME=de_DE.UTF-8 LC_ADDRESS=de_DE.UTF-8 LC_TELEPHONE=de_DE.UTF-8 LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=de_DE.UTF-8 LC_ALL=