ansible --version
ERROR: Ansible requires the locale encoding to be UTF-8; Detected None.
Hacked with explicit assignment of LC_ALL:
LC_ALL=C.UTF-8 ansible --version
ansible [core 2.14.1]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/strayguin/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.10/site-packages/ansible
ansible collection location = /home/strayguin/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.10.8 (main, Nov 1 2022, 14:18:21) [GCC 12.2.0] (/usr/bin/python)
jinja version = 3.1.2
libyaml = True
Current locale settings in /etc/locale.conf
LANG=en_US.UTF-8
LANGUAGE=en_US
LC_ALL=C
Where's this error come from? https://github.com/ansible/ansible/blob/v2.14.1/lib/ansible/cli/__init__.py#L58
try:
locale.setlocale(locale.LC_ALL, '')
dummy, encoding = locale.getlocale()
except (locale.Error, ValueError) as e:
raise SystemExit(
'ERROR: Ansible could not initialize the preferred locale: %s' % e
)
if not encoding or encoding.lower() not in ('utf-8', 'utf8'):
raise SystemExit('ERROR: Ansible requires the locale encoding to be UTF-8; Detected %s.' % encoding)
This change was added recently: ansible/ansible#78175, ansible/ansible#78175 (comment)
With the latest change,
C
is not allowed.
What should locales be for my system? https://wiki.archlinux.org/title/locale#LC_ALL:_troubleshooting
The locale set for this variable will always override LANG and all the other LC_* variables, whether they are set or not. If LC_ALL is set to C, it will also override LANGUAGE.
LC_ALL is the only LC_* variable which cannot be set in locale.conf files: it is meant to be used only for testing or troubleshooting purposes, for example in /etc/profile.
~ https://wiki.archlinux.org/title/locale#LC_ALL:_troubleshooting
Fixed by unsetting LC_ALL
LC_ALL= ansible --version
ansible [core 2.14.1]
...
Applied to locale.conf
LANG=en_US.UTF-8
LANGUAGE=en_US
Thanks. Saved my Sunday :)