# Running from source forces new terminals to cd into ansible's source dir

**URL:** <https://forum.ansible.com/t/running-from-source-forces-new-terminals-to-cd-into-ansibles-source-dir/17287>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [January 16, 2015, 12:57am UTC](https://forum.ansible.com/t/running-from-source-forces-new-terminals-to-cd-into-ansibles-source-dir/17287 "2015-01-16T00:57:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Reagan](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@David\_Reagan](https://forum.ansible.com/u/David_Reagan)\
**Post date:** [January 16, 2015, 12:57am UTC](https://forum.ansible.com/t/running-from-source-forces-new-terminals-to-cd-into-ansibles-source-dir/17287/1 "2015-01-16T00:57:37Z")

</div>

So, I’m not sure this is an Ansible issue, but it might be, and I bet some of you could help me fix it anyway.

I’m running Ansible from source. As described here [http://docs.ansible.com/intro\_installation.html#running-from-source](http://docs.ansible.com/intro_installation.html#running-from-source) I have the repo in ~/vendor/ansible

A while back, after updating to the latest code, my terminals started cd’ing into ~/vendor/ansible whenever I created a new terminal.

It does this because I have my .zshrc file set up to automatically run `source ./hacking/env-setup`. Basically, I don’t want to have to run that command every time I reboot my machine.

First, is that the behaviour that the env-setup script is supposed display?

Second, is there a better way to run the source command automatically? Maybe some kind of if statement in my zshrc file that checks to make sure the hacking settings have been applied?

Thanks!

I’m using Ubuntu 14.04, Terminator, and Zsh, if it matters.

---

<div class="post-metadata">

**Author:** ![Greg\_Andrews](https://avatars.discourse-cdn.com/v4/letter/g/6bbea6/32.png) [@Greg\_Andrews](https://forum.ansible.com/u/Greg_Andrews)\
**Post date:** [January 16, 2015, 11:13am UTC](https://forum.ansible.com/t/running-from-source-forces-new-terminals-to-cd-into-ansibles-source-dir/17287/2 "2015-01-16T11:13:17Z")

</div>

I would put that source command into the zsh script that's invoked when you  
start an interactive shell rather than the file that's invoked on every  
shell.

&nbsp;&nbsp;-Greg

---

<div class="post-metadata">

**Author:** ![David\_Reagan](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@David\_Reagan](https://forum.ansible.com/u/David_Reagan)\
**Post date:** [January 16, 2015, 5:28pm UTC](https://forum.ansible.com/t/running-from-source-forces-new-terminals-to-cd-into-ansibles-source-dir/17287/3 "2015-01-16T17:28:55Z")

</div>

Well, I did some experimenting with the files listed [http://zsh.sourceforge.net/Doc/Release/Files.html#Files](http://zsh.sourceforge.net/Doc/Release/Files.html#Files)

A) env-setup has to be sourced for every terminal window.

B) If I place the source command in one of zsh’s files that only gets run once, then new terminals need me to source env-setup again.

Also, I know I’m not very fluent in bash, but why is env-setup causing my terminal to change directories? I see no ‘cd’ commands in the file at all.

So, I think I can just set the various env values manually. But what about the gen\_egg\_info() function? And which vars do I really need to set?

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [January 18, 2015, 3:23am UTC](https://forum.ansible.com/t/running-from-source-forces-new-terminals-to-cd-into-ansibles-source-dir/17287/4 "2015-01-18T03:23:37Z")

</div>

> Well, I did some experimenting with the files listed [http://zsh.sourceforge.net/Doc/Release/Files.html#Files](http://zsh.sourceforge.net/Doc/Release/Files.html#Files)
> 
> A) env-setup has to be sourced for every terminal window.
> 
> B) If I place the source command in one of zsh’s files that only gets run once, then new terminals need me to source env-setup again.
> 
> Also, I know I’m not very fluent in bash, but why is env-setup causing my terminal to change directories? I see no ‘cd’ commands in the file at all.

Does this also happen if you source env-setup outside of zsh’s startup scripts?

I bet the pushd popd commands are what’s leaving you in the wrong directories. However i’m using zsh with env-setup (not in my startup scripts though) and not run into any problems. Might be some interaction with other zsh initialization… zsh is very flexible so something different between your config and mine could be causing this.

-Toshio

---

<div class="post-metadata">

**Author:** ![Tom\_Bamford](https://avatars.discourse-cdn.com/v4/letter/t/c2a13f/32.png) [@Tom\_Bamford](https://forum.ansible.com/u/Tom_Bamford)\
**Post date:** [January 18, 2015, 4:48am UTC](https://forum.ansible.com/t/running-from-source-forces-new-terminals-to-cd-into-ansibles-source-dir/17287/5 "2015-01-18T04:48:25Z")

</div>

Hi David

I’m also using zsh although usually only source env-setup when I need it. If I do source it from ~/.zshrc, it doesn’t change my working directory.

Does adding `set -x` to the beginning of, and `set +x` to the end of the env-setup file offer any clues?

​

---

<div class="post-metadata">

**Author:** ![David\_Reagan](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@David\_Reagan](https://forum.ansible.com/u/David_Reagan)\
**Post date:** [January 23, 2015, 11:25pm UTC](https://forum.ansible.com/t/running-from-source-forces-new-terminals-to-cd-into-ansibles-source-dir/17287/6 "2015-01-23T23:25:45Z")

</div>

To those who replied, thanks!

When I got to my work office computer, it wasn’t cd’ing on me anymore. When I finally had time today to try and test things here on my home computer, it stopped cd’ing on me after I updated to the latest devel commit.

So, everything is working fine now. Go figure…
