dyuri / xontrib-langenv

pyenv integration for xonsh
MIT License
12 stars 3 forks source link

Error if pyenv-virtualenv not installed #2

Open paugier opened 4 years ago

paugier commented 4 years ago

If pyenv-virtualenv is not installed, I get:

xonsh: For full traceback set: $XONSH_SHOW_TRACEBACK = True
subprocess.CalledProcessError: Command '['bash', '-c', 'source "/home/pierre/.bashrc"\npyenv virtualenv-init -\n']' returned non-zero exit status 1.
dyuri commented 4 years ago

Sorry, I missed this issue completely. Checking.

dyuri commented 4 years ago

Hmm, I can't reproduce this, for me if pyenv-virtualenv is not installed then the result of $(pyenv virtualenv-init -) is an empty string, and nothing happens (no exceptions). Using xonsh 0.9.18. If you still have this issue, please enable $XONSH_SHOW_TRACEBACK and provide more details.

mjmare commented 3 years ago

When starting a XONSH shell (with xontrib load pyenv in .xonshrc) I get the message:

pyenv: no such command `virtualenv-init'

(I have $XONSH_SHOW_TRACEBACK set to True).

Then I brew installed pyenv-virtualenv. It makes the message/error go away. However, it seems pyenv virtualenv myvenv + pyenv activate myvenv does NOT work properly the virtualenv is not activated.

dyuri commented 3 years ago

I've commited a change into master to suppress the "no such command" error while checking for pyenv-virtualenv, if you have a chance, please check.

The other issue is more interesting, for me it works as inteded:

❯ pyenv virtualenv test
Looking in links: /tmp/tmpahxyqpfz
Requirement already satisfied: setuptools in /home/dyuri/.pyenv/versions/test/lib/python3.9/site-packages (56.0.0)
Requirement already satisfied: pip in /home/dyuri/.pyenv/versions/test/lib/python3.9/site-packages (21.1.3)
❯ pyenv activate test
pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
❯ which python
/home/dyuri/.pyenv/shims/python
❯ $VIRTUAL_ENV
'/home/dyuri/.pyenv/versions/test'
❯ pyenv deactivate cica
❯ $VIRTUAL_ENV
Traceback (Most recent call last):
1 <xonsh-code> <module> -->
KeyError: 'Unknown environment variable: $VIRTUAL_ENV'
❯ pyenv virtualenv-delete test
pyenv-virtualenv: remove /home/dyuri/.pyenv/versions/test? y

Is the pyenv alias working in your session? You can check that this way:

❯ which pyenv
<function create_alias.<locals>.pyenv at 0x7faefcbb58b0>
mjmare commented 3 years ago

I brew uninstalled pyenv-virtualenv. I did a brew update+upgrade. I brew uninstalled + installed pyenv. I still get the error message. Maybe you haven't pushed to Home-brew (don't know how that works)?

dyuri commented 3 years ago

No, I did not, and no, pyenv-virtualenv is not my package, xontrib-pyenv is. A minute and I publish a new version to PyPI.

mjmare commented 3 years ago

I see. What is the best procedure to get your latest version?

dyuri commented 3 years ago

New version (1.0.6) released to PyPI (https://pypi.org/project/xontrib-pyenv/), I hope brew uses that.

dyuri commented 3 years ago

I'm using pip to install python packages, but I use Linux (I suppose you use Mac).

mjmare commented 3 years ago

Everything seems to work now, including the virtualenv stuff. Great! Thanks for the prompt action.

For others who may read this: xpip uninstall xontrib-pyenv, followed by a similar install. If pyenv-virtualenv is not installed: no more error message. With pyenv-virtualenv installed, pyenv virtualenvs work.

BTW it would be useful if you could add to the contributing-pyenv docs that no other installation steps (as stipulated in the pyenv docs) are necessary.