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

Activation / Deactivation of virtualenvs works only once #48

Closed
nopper opened this issue Oct 12, 2014 · 4 comments
Closed

Activation / Deactivation of virtualenvs works only once #48

nopper opened this issue Oct 12, 2014 · 4 comments

Comments

@nopper
Copy link

nopper commented Oct 12, 2014

I have a project in which I created a .python-version file. In this case I have something like:

$ cat project/.python-version
project-2.7.8

Whenever I change my directory to the project root pyenv-virtualenv is invoked correctly. When I leave the virtual env is deactivated.

$ cd project
pyenv-virtualenv: activate project-2.7.8
(project-2.7.8) $ cd ..
pyenv-virtualenv: deactivate project-2.7.8

The problem is that if I re-enter in the project/ directory is not activated anymore.

$ cd project
# Nothing happens
$

It doesn't matter how many times I try, the activation seems to work only once. Successive attempts seem to ignore the virtualenv indicated in the .python-version file.

@yyuu
Copy link
Collaborator

yyuu commented Oct 12, 2014

The pyenv virtualenv-init persists the state in environment variables of PYENV_ACTIVATE and PYENV_DEACTIVATE. If you have problem with activating virtualenv, please restart your shell or unset those environment variables.

https://github.com/yyuu/pyenv-virtualenv/blob/5252cd07778478e61ffd13443bfc6c4f9cba5e73/bin/pyenv-virtualenv-init#L78

@nopper
Copy link
Author

nopper commented Oct 12, 2014

Surely restarting the shell or unsetting the env variables solves the problem. But what I was expecting i a consistent activation / deactivation mechanism.

What I suggest is to unset the PYENV_DEACTIVATE whenever a deactivation is triggered in an automatic fashion without requiring the user to do so. This apparently solves the issue for me.

Could you consider such addition?

@yyuu
Copy link
Collaborator

yyuu commented Oct 12, 2014

The current behaviour must not be expected for most users. I think this is a kind of bug of current impl.

As you mentioned, PYENV_DEACTIVATED should not persist after automatically triggered deactivation. I'll try to fix it in #47.

@nopper
Copy link
Author

nopper commented Oct 12, 2014

Ok closing this and following #47

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

No branches or pull requests

2 participants