Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyenv and ansible-playbook: Not a directory error #580

Closed
YAmikep opened this issue Apr 21, 2016 · 4 comments · Fixed by #1216
Closed

pyenv and ansible-playbook: Not a directory error #580

YAmikep opened this issue Apr 21, 2016 · 4 comments · Fixed by #1216

Comments

@YAmikep
Copy link

YAmikep commented Apr 21, 2016

I have ansible and pyenv installed.

When using the ansible-playbook command, I get this error message:

vagrant@dev:~$ ansible-playbook
/home/vagrant/pyenv/libexec/pyenv: line 43: cd: ansible: Not a directory

Any idea why?

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/33195390-pyenv-and-ansible-playbook-not-a-directory-error?utm_campaign=plugin&utm_content=tracker%2F282009&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F282009&utm_medium=issues&utm_source=github).
@yyuu
Copy link
Contributor

yyuu commented Apr 22, 2016

Please show me the output of 'PYENV_DEBUG=1 ansible-playbook'. I guess you have stale shim script.

@YAmikep
Copy link
Author

YAmikep commented Apr 22, 2016

@yyuu here is the output:
pyenv_debug.txt

@yyuu
Copy link
Contributor

yyuu commented May 2, 2016

@YAmikep Sorry for delay....

At the beginning of the debug print, I found PYENV_FILE_ARG=/usr/bin/ansible-playbook in the script. It must mean you have ansible-playbook executables in both /usr/bin and your /home/vagrant/pyenv and the former has precedence in your ${PATH} configuration.

Basically I'd recommend you to have pyenv's shims path at almost top of your ${PATH}. Giving precedence to system paths (e.g. /usr/bin, /bin) might cause problem like yours. Please review your ${PATH} and try again.

+ program=python
+ [[ python = \p\y\t\h\o\n* ]]
+ for arg in '"$@"'
+ case "$arg" in
+ '[' -f /usr/bin/ansible-playbook ']'
+ export PYENV_FILE_ARG=/usr/bin/ansible-playbook
+ PYENV_FILE_ARG=/usr/bin/ansible-playbook
+ break
+ export PYENV_ROOT=/home/vagrant/pyenv
+ PYENV_ROOT=/home/vagrant/pyenv
+ exec /home/vagrant/pyenv/libexec/pyenv exec python /usr/bin/ansible-playbook
+ [pyenv:23] enable -f /home/vagrant/pyenv/libexec/../libexec/pyenv-realpath.dylib realpath
+ [pyenv:29] '[' -z '' ']'
++ [pyenv:31] type -p greadlink readlink
++ [pyenv:31] head -1
+ [pyenv:31] READLINK=/bin/readlink
+ [pyenv:32] '[' -n /bin/readlink ']'
+ [pyenv:53] '[' -z /home/vagrant/pyenv ']'
+ [pyenv:56] PYENV_ROOT=/home/vagrant/pyenv
+ [pyenv:58] export PYENV_ROOT
+ [pyenv:61] '[' -z '' ']'
+ [pyenv:62] '[' -n /usr/bin/ansible-playbook ']'
+ [pyenv:63] '[' -L /usr/bin/ansible-playbook ']'
++ [pyenv:64] abs_dirname /usr/bin/ansible-playbook
++ [pyenv:39] local cwd=/home/vagrant
++ [pyenv:40] local path=/usr/bin/ansible-playbook
++ [pyenv:42] '[' -n /usr/bin/ansible-playbook ']'
++ [pyenv:43] cd /usr/bin
++ [pyenv:44] local name=ansible-playbook
+++ [pyenv:45] resolve_link ansible-playbook
+++ [pyenv:35] /bin/readlink ansible-playbook
++ [pyenv:45] path=ansible
++ [pyenv:42] '[' -n ansible ']'
++ [pyenv:43] cd ansible
/home/vagrant/pyenv/libexec/pyenv: line 43: cd: ansible: Not a directory             

@gretel
Copy link

gretel commented May 2, 2016

@yyuu thanks for looking into it. manually messing with path elements might be difficult.
for me, this condition only occurs in combination with pyenv-virtualenv when pyenv activateing a virtualenv (which is located below .pyenv by default = not at the same location).
manually setting up one using virtualenv . and using pyenv-virtualenv subsequently does work fine, lacking the comfort, though.
i'd like to suggest to detect this case in pyenv itself and sort the elements of PATH accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants