# shell issue

**URL:** <https://forum.ansible.com/t/shell-issue/12723>\
**Category:** Ansible Project\
**Tags:** ansible-project\
**Created:** [April 26, 2013, 3:57pm UTC](https://forum.ansible.com/t/shell-issue/12723 "2013-04-26T15:57:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michel\_Blanc1](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@Michel\_Blanc1](https://forum.ansible.com/u/Michel_Blanc1)\
**Post date:** [April 26, 2013, 3:57pm UTC](https://forum.ansible.com/t/shell-issue/12723/1 "2013-04-26T15:57:15Z")

</div>

This is because when Ansible does "sudo vagrant", it doesn't use an  
interactive shell thus your .bash stuff won't be read, and ~/.rvm/bin is  
probably not appended to yout path.

I do :  
shell bash -lc 'cd; rvm install ...'

to circumvent this (which is not much cleaner 😛 )

M

---

<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:** [April 26, 2013, 4:25pm UTC](https://forum.ansible.com/t/shell-issue/12723/2 "2013-04-26T16:25:42Z")

</div>

You could use the ‘environment’ keyword in ansible to set your path variables if need be.

---

<div class="post-metadata">

**Author:** ![lstask](https://avatars.discourse-cdn.com/v4/letter/l/b5a626/32.png) [@lstask](https://forum.ansible.com/u/lstask)\
**Post date:** [April 27, 2013, 4:51pm UTC](https://forum.ansible.com/t/shell-issue/12723/3 "2013-04-27T16:51:52Z")

</div>

Got it - thanks!

Can you possibly shed some light on why the configured user’s shell environment is not available when running the ‘shell’ action?

Thanks,  
Liam

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [April 27, 2013, 5:25pm UTC](https://forum.ansible.com/t/shell-issue/12723/4 "2013-04-27T17:25:00Z")

</div>

Michel already answered this.

---

<div class="post-metadata">

**Author:** ![lstask](https://avatars.discourse-cdn.com/v4/letter/l/b5a626/32.png) [@lstask](https://forum.ansible.com/u/lstask)\
**Post date:** [April 27, 2013, 5:37pm UTC](https://forum.ansible.com/t/shell-issue/12723/5 "2013-04-27T17:37:35Z")

</div>

Ah, I guess my question should have been, “why doesn’t ansible either use an interactive shell (or some other mechanism) to make the user’s environment available?”.

Thanks,  
Liam

---

<div class="post-metadata">

**Author:** ![Michel\_Blanc1](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@Michel\_Blanc1](https://forum.ansible.com/u/Michel_Blanc1)\
**Post date:** [May 7, 2013, 4:26pm UTC](https://forum.ansible.com/t/shell-issue/12723/6 "2013-05-07T16:26:47Z")

</div>

Well this has been tried (asking ansible to add -i in sudo runs) in the  
past. However, many side effects came up (some ansible runs were stuck)  
so the patch has been reverted since.

The best way to handle is is probably to write rbenv/rvm modules.

M

---

<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:** [May 7, 2013, 8:08pm UTC](https://forum.ansible.com/t/shell-issue/12723/7 "2013-05-07T20:08:09Z")

</div>

Plus I really don’t want the user’s environment (path, etc) as part of the equation.

The goal should be to centrally manage things with authority and not trust the user env.
