AstraLuma / xontrib-avox

autovox policy based on project directories
GNU General Public License v3.0
10 stars 3 forks source link

Nested virtual environments #6

Open eode opened 2 years ago

eode commented 2 years ago

This is both a feature request and a bug report.

Bug

When in a subdir within a recognized avox dir that triggers a virtual environment, typing avox create replies with "Working directory already has a virtual environment" -- but then proceeds to exit that virtual environment. When using cd to navigate out of the dir that has the virtualenv associated, it causes a traceback:

Example:


user@host ~/Projects $ mkdir -p example/foo
user@host ~/Projects $ cd example
user@host ~/Projects/example $ avox create
Creating virtual environment example...
Using Interpreter: /usr/bin/python3
Activating...
(example) user@host ~/Projects/example $ cd foo
(example) user@host ~/Projects/example/foo $ avox create
Working directory already has a virtual environment.
user@host ~/Projects/example/foo $ cd ..
user@host ~/Projects/example $ cd ..
xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename>
Exception raised in event handler; ignored.
Traceback (most recent call last):
  File "/path/to/lib/python3.10/dist-packages/xonsh/__amalgam__.py", line 9768, in fire
    rv = handler(**kwargs)
  File "/path/to/lib/python3.10/dist-packages/xontrib/autovox.py", line 85, in cd_handler
    check_for_new_venv(Path(newdir), Path(olddir))
  File "/path/to/lib/python3.10/dist-packages/xontrib/autovox.py", line 77, in check_for_new_venv
    vox.deactivate()
  File "/path/to/lib/python3.10/dist-packages/xontrib/voxapi.py", line 397, in deactivate
    raise NoEnvironmentActive("No environment currently active.")
xontrib.voxapi.NoEnvironmentActive: No environment currently active.
user@host ~/Projects $

Feature Request

It would be very nice to be able to have nested venvs. Although I think they should be truly nested, that's not an important feature, and it's not what vox does. So, the desired behavior would be:

In any case, thanks for your Xontrib, it's really useful!

AstraLuma commented 2 years ago

This logic is no longer part of avox and is now part of autovox in xonsh proper. (avox is just one policy for autovox.)

Please report this to the xonsh project.