# Shouldn't run\_command expand user on cwd ?

**URL:** <https://forum.ansible.com/t/shouldnt-run-command-expand-user-on-cwd/15584>\
**Category:** Ansible Developer\
**Created:** [July 1, 2014, 2:05pm UTC](https://forum.ansible.com/t/shouldnt-run-command-expand-user-on-cwd/15584 "2014-07-01T14:05:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michel\_Blanc](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@Michel\_Blanc](https://forum.ansible.com/u/Michel_Blanc)\
**Post date:** [July 1, 2014, 2:05pm UTC](https://forum.ansible.com/t/shouldnt-run-command-expand-user-on-cwd/15584/1 "2014-07-01T14:05:36Z")

</div>

Hi,

I came across an issue today using the npm module where a path passed  
via the 'path' parameter wasn't being user-expanded.

I tracked this down to the run\_command function in  
lib/ansible/module\_utils/basic.py where the cwd param (originally 'path'  
in npm) isn't user-expanded (e.g. ~foo -\> /home/foo).

While the patch is trivial, I find it rather weird to stumble across  
this, so I prefer to ask first. I guess that such an issue would have  
come up already (unless all modules using paths do their own  
user-expansion up front).

So, is it a module's responsabilty to call os.path.expanduser for paths,  
or should run\_module do it ?

Thanks for your clues,

M

---

<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:** [July 1, 2014, 7:00pm UTC](https://forum.ansible.com/t/shouldnt-run-command-expand-user-on-cwd/15584/2 "2014-07-01T19:00:35Z")

</div>

The modules should do it.

Otherwise, generically, the module can’t know what is a path and what is not, and plus it must occur on the remote side anyway in some cases, but not always (as there are modules with local components)

More of an ansible-devel topic, FWIW, if you want to join that list.
