justinmayer / virtualfish

Fish shell tool for managing Python virtual environments
MIT License
1.06k stars 100 forks source link

Naive `python` call in `vf uninstall` yields error #168

Closed Prodeguerriero closed 4 years ago

Prodeguerriero commented 4 years ago

Setup

MacOs Catalina 10.15.4 Fish 3.1.2 installed via Homebrew Python 3.7.7 installed via Homebrew VirtualFish 2.2.1 installed via pip VirtualFish loader installed via vf install (~/.config/fish/conf.d)

Objective

Uninstall the loader with vf uninstall

Expected behavior

Actual behaviour

Workaround

Possible cause

The function __vf_uninstall calls for python, but on MacOS (or at least my installation) python still links to python 2.7.

justinmayer commented 4 years ago

Thank you for pointing this out, Gabriele. The problem was that someone used a naive python invocation in the vf uninstall function: https://github.com/justinmayer/virtualfish/blob/adfcb0c5ed4596a3bee6b71be319a425aa2f9542/virtualfish/virtual.fish#L498

Normally, that shouldn't be a problem. But if the Python interpreter used to pip install virtualfish is different than the first instance of python on your $PATH, then uninstalling could result in the error you encountered.

When VirtualFish is Pip-installed, the specific Python interpreter used to invoke Pip is recorded in the VirtualFish loader as VIRTUALFISH_PYTHON_EXEC. Therefore, during the uninstall process, a more sensible approach would be to use the Python interpreter specified in that variable instead of naively invoking python.

justinmayer commented 4 years ago

I believe I have addressed this via 3e505d2, which I just published as VirtualFish 2.2.2.