# Weird bug with locale

**URL:** <https://forum.ansible.com/t/weird-bug-with-locale/15147>\
**Category:** Ansible Project\
**Created:** [May 2, 2014, 6:42pm UTC](https://forum.ansible.com/t/weird-bug-with-locale/15147 "2014-05-02T18:42:38Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrei\_Pashkin](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@Andrei\_Pashkin](https://forum.ansible.com/u/Andrei_Pashkin)\
**Post date:** [May 2, 2014, 6:42pm UTC](https://forum.ansible.com/t/weird-bug-with-locale/15147/1 "2014-05-02T18:42:38Z")

</div>

I’m trying to set up provisioning for Vagrant VM with Ansible, but constantly get an error:

> ```auto
> locale: Cannot set LC_ALL to default locale: No such file or directory
> 
> ```

Here is the full [output.](https://gist.github.com/AndrewPashkin/5a800dc324c7d9682373)

I’ve tried to place this task in `pre_tasks`:

> `- name: set up locale`  
> `apt: pkg=language-pack-en`

And also tried to put this in task that fails:

> `environment:`  
> `LC_ALL: "en_US.UTF-8"`

But it didnt helped.  
Does anybody saw an error like that, and found solutions? Kindly help.

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [May 2, 2014, 6:55pm UTC](https://forum.ansible.com/t/weird-bug-with-locale/15147/2 "2014-05-02T18:55:14Z")

</div>

Just yesterday we merged in a slight change in the way that we’re setting the localization environment and other environment variables. What version are you running to produce the above output?

---

<div class="post-metadata">

**Author:** ![Andrei\_Pashkin](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@Andrei\_Pashkin](https://forum.ansible.com/u/Andrei_Pashkin)\
**Post date:** [May 2, 2014, 7:11pm UTC](https://forum.ansible.com/t/weird-bug-with-locale/15147/3 "2014-05-02T19:11:35Z")

</div>

I use . I thought that this is the issue with Ubuntu (I use ) or with Vagrant. Because there is a lot of topics on the internet about such errrors, but all of them in general solved with setting up and re-generation of locales - doesnt work in my case. Is there some workarounds with version for this? Or maybe you can describe what actually cause the error, because I’m totally can’t get why it happens. Also I do some debugging right now - check the - I’ve discovered, that if first task is commented - error does not being throwed.

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [May 2, 2014, 7:24pm UTC](https://forum.ansible.com/t/weird-bug-with-locale/15147/4 "2014-05-02T19:24:50Z")

</div>

Previously in 1.5.x we set LANG=C specifically to ensure a consistent shell environment. This does create problems for Unicode however, so recently we modified the way it works. In your case, you should set ‘module\_lang = en\_RU.UTF-8’ (or en\_US.UTF-8 if you wish) in your ansible.cfg under the “[defaults]” section. That value will then be used instead of “C”.

---

<div class="post-metadata">

**Author:** ![Andrei\_Pashkin](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@Andrei\_Pashkin](https://forum.ansible.com/u/Andrei_Pashkin)\
**Post date:** [May 2, 2014, 7:35pm UTC](https://forum.ansible.com/t/weird-bug-with-locale/15147/5 "2014-05-02T19:35:25Z")

</div>

> Previously in 1.5.x we set LANG=C specifically to ensure a consistent shell environment. This does create problems for Unicode however, so recently we modified the way it works. In your case, you should set 'module\_lang = en\_RU.UTF-8' (or en\_US.UTF-8 if you wish) in your ansible.cfg under the "[defaults]" section. That value will then be used instead of "C".

If I want to override this variable only for that project or playbook and keep everything else with default values, what is the cleanest way to do that?  
Docs says that:

> Settings in files are not merged together.

So, I need to copy all stuff from /etc/ansible/ansible.cfg to myproj/ansible.cfg and tweak needed values?

There line in ansible.cfg:

> nearly all parameters can be overridden in ansible-playbook

Does it mean, that I can just put module\_lang setting in a playbook?

---

<div class="post-metadata">

**Author:** ![Andrei\_Pashkin](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@Andrei\_Pashkin](https://forum.ansible.com/u/Andrei_Pashkin)\
**Post date:** [May 4, 2014, 8:27am UTC](https://forum.ansible.com/t/weird-bug-with-locale/15147/6 "2014-05-04T08:27:20Z")

</div>

False alert! I didnt noticed error messages "cannot allocate memory" in the middle of output. I've just increased VMs memory and everything became OK.

---

<div class="post-metadata">

**Author:** ![Andrei\_Pashkin](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@Andrei\_Pashkin](https://forum.ansible.com/u/Andrei_Pashkin)\
**Post date:** [May 22, 2014, 11:22am UTC](https://forum.ansible.com/t/weird-bug-with-locale/15147/7 "2014-05-22T11:22:30Z")

</div>

By the way, I was found that locale can be fixed with this:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- name: set up locale  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shell: echo "echo $'LANGUAGE=en\_US.UTF-8\n' \> /etc/default/locale" | sudo -s;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo "echo $'LANG=en\_US.UTF-8\n' \>\> /etc/default/locale" | sudo -s;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo "echo $'LC\_ALL=en\_US.UTF-8\n' \>\> /etc/default/locale"

> sudo -s;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo "echo $'LC\_MESSAGES=POSIX\n' \>\> /etc/default/locale"

> sudo -s;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;locale-gen en\_US.UTF-8;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dpkg-reconfigure locales;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;touch /etc/locale\_configured;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;creates=/etc/locale\_configured

Works on Ubuntu 12.04

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [May 23, 2014, 12:20pm UTC](https://forum.ansible.com/t/weird-bug-with-locale/15147/8 "2014-05-23T12:20:18Z")

</div>

FWIW, if you have something like that again, the ‘script’ module makes for cleaner playbooks.

It just pushes and runs a remote script.
