Skip to content

vox activate fails when currently active virtualenv is removed #3

@ghost

Description

@ghost

xonfig

Clean install (inside a temp virtualenv), started as xonsh --no-rc

Details
$ xonfig
+------------------+----------------------+
| xonsh            | 0.9.13.dev1          |
| Git SHA          | 9f7ccc65             |
| Commit Date      | Oct 15 17:14:50 2019 |
| Python           | 3.6.9                |
| PLY              | 3.11                 |
| have readline    | True                 |
| prompt toolkit   | 3.0.3                |
| shell type       | prompt_toolkit2      |
| pygments         | 2.5.2                |
| on posix         | True                 |
| on linux         | True                 |
| distro           | unknown              |
| on darwin        | False                |
| on windows       | False                |
| on cygwin        | False                |
| on msys2         | False                |
| is superuser     | False                |
| default encoding | utf-8                |
| xonsh encoding   | utf-8                |
| encoding errors  | surrogateescape      |
+------------------+----------------------+

Expected Behavior

The old virtualenv should be deactivated and the new virtualenv should be activated

Current Behavior

An error message is shown, old virtualenv is deactivated but new virtualenv isn't activated.

Steps to Reproduce

Open 2 xonsh instances.

In xonsh instance 1:

$  xontrib load vox
$  vox create foo
$  vox create bar
$  vox activate foo

In xonsh instance 2:

$  vox remove foo

or just remove or rename the virtualenv directory directly.

Back in xonsh instance 1:

$  vox activate bar
This environment doesn't exist. Create it with "vox new bar".

Note that a second vox activate bar does succeed (as the foo virtualenv has been deactivated by the first attempt):

$  vox activate bar
Activated "bar".

Additional info

Some quick debugging seems to indicate the problem is due to https://github.com/xonsh/xonsh/blob/master/xontrib/voxapi.py#L288 , the ve.bin dir doesn't exist (obviously, the virtualenv got removed ;) ) so the else: part of the for loop gets triggered, raising a KeyError. This gets caught by the except KeyError: part in cmd_activate() ( https://github.com/xonsh/xonsh/blob/master/xontrib/vox.py#L161 ).

For community

⬇️ Please click the 👍 reaction instead of leaving a +1 or 👍 comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions