# gem module and gem executable path

**URL:** <https://forum.ansible.com/t/gem-module-and-gem-executable-path/13050>\
**Category:** Ansible Project\
**Created:** [July 1, 2013, 8:38pm UTC](https://forum.ansible.com/t/gem-module-and-gem-executable-path/13050 "2013-07-01T20:38:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karri\_Niemela](https://avatars.discourse-cdn.com/v4/letter/k/e9bcb4/32.png) [@Karri\_Niemela](https://forum.ansible.com/u/Karri_Niemela)\
**Post date:** [July 1, 2013, 8:38pm UTC](https://forum.ansible.com/t/gem-module-and-gem-executable-path/13050/1 "2013-07-01T20:38:38Z")

</div>

Hi all. Trying to bootstrap centos 6.4 based servers.

So I’ve got a simple task;

- name: install bundler  
gem: name=bundler state=present

And its failing because;  
Because msg: Failed to find required executable gem

Now the reason for this is that my gem executable is in /usr/local/bin

So, how to overcome this?

---

<div class="post-metadata">

**Author:** ![James\_Martin2](https://avatars.discourse-cdn.com/v4/letter/j/b9e5f3/32.png) [@James\_Martin2](https://forum.ansible.com/u/James_Martin2)\
**Post date:** [July 2, 2013, 6:32pm UTC](https://forum.ansible.com/t/gem-module-and-gem-executable-path/13050/2 "2013-07-02T18:32:05Z")

</div>

3 things,

patch the gem module to support an alternate path for the gem binary  
use the /etc/alternatives approach  
call the gem command directly with the command or shell module

- James

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 2, 2013, 6:35pm UTC](https://forum.ansible.com/t/gem-module-and-gem-executable-path/13050/3 "2013-07-02T18:35:15Z")

</div>

The first one seems best to me, though you may also consider using the “environment” keyword in ansible to set the path.

though I like option 1.

Send me a pull request and I’ll gladly take it. The parameter should be called gem\_path, I’d think.

---

<div class="post-metadata">

**Author:** ![Karri\_Niemela](https://avatars.discourse-cdn.com/v4/letter/k/e9bcb4/32.png) [@Karri\_Niemela](https://forum.ansible.com/u/Karri_Niemela)\
**Post date:** [July 3, 2013, 8:22pm UTC](https://forum.ansible.com/t/gem-module-and-gem-executable-path/13050/4 "2013-07-03T20:22:17Z")

</div>

Or four;)

Change sudoers Defaults secure\_path to include /usr/local/bin

tiistai, 2. heinäkuuta 2013 21.32.05 UTC+3 James Martin kirjoitti:

---

<div class="post-metadata">

**Author:** ![Mickael\_Remond](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@Mickael\_Remond](https://forum.ansible.com/u/Mickael_Remond)\
**Post date:** [October 14, 2013, 1:15pm UTC](https://forum.ansible.com/t/gem-module-and-gem-executable-path/13050/5 "2013-10-14T13:15:27Z")

</div>

Hello Michael,

I implemented option 1 in this pull request:  
[https://github.com/ansible/ansible/pull/4497](https://github.com/ansible/ansible/pull/4497)

This is my first Python code since probably … 10 years 🙂  
Please, let me know if you need any changes.

Kind regards,

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [October 14, 2013, 2:16pm UTC](https://forum.ansible.com/t/gem-module-and-gem-executable-path/13050/6 "2013-10-14T14:16:11Z")

</div>

Thanks, see comment on the ticket!
