MichaelAquilina/zsh-autoswitch-virtualenv

mkvenv: Random suffix generator broken when 'python' is not in $PATH

moha-gh opened this issue · 4 comments

Issue Details

KDE neon (basically Ubuntu LTS + bleeding edge KDE) apparently doesn't have a python in $PATH by default - you'll need to explicitly call either python2 or python3. This breaks the generation of the random virtualenv suffix introduced with #166. I get a command not found error when calling mkvenv and end up with a virtualenv without a suffix. Everything apart from that works fine (i.e. the venv automatically picks Python3, even though it is not in $PATH).

Since that seems to be the only place in the plugin that expects a python, I'd be great if there could be some check to warn the user if it isn't available. Or possibly use a different method (mktemp -u XXXX comes to mind, but I have no idea whether that would be available on all supported platforms ❔ )

Operating System (uname -a)

Linux 5.13.0-35-generic #40~20.04.1-Ubuntu SMP Mon Mar 7 09:18:32 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

zsh version (zsh --version)

zsh 5.8 (x86_64-ubuntu-linux-gnu)

autoswitch-virtualenv version

3.5.0

How is zsh-autoswitch-virtualenv installed?

  • oh-my-zsh

Steps to reproduce the issue

cd /tmp
mkdir foo
cd foo
mkvenv
Command 'python' not found, did you mean:
  command 'python3' from deb python3
  command 'python' from deb python-is-python3
Creating foo- virtualenv
[...]
Switching virtualenv: foo- [🐍Python 3.8.10]

gist link to your zshrc

n/a

Python not being in your path is an issue though 🤔 Maybe we can make this more explicit in the README but we would expect a python binary being available in your path considering this is a plugin related to python virtualenvs

We could also warn the user that they need to do this if we detect this issue as you suggested

Python not being in your path is an issue though thinking Maybe we can make this more explicit in the README but we would expect a python binary being available in your path considering this is a plugin related to python virtualenvs

A reasonable assumption, yes. Since I haven't encountered any other issue with this setup so far (as mentioned, the venv is working fine - same goes for tools like pip or development in VS Code) I still wanted to bring it up :) It'd be happy to file a PR that extends the documentation accordingly.

Go for it @moha-gh :)

The new check added with #172 works as expected for me. To make python available in $PATH I've installed the python-is-python3 package via apt install.