dmerejkowsky / dmenv

Simple and practical virtualenv manager for Python
https://tankerhq.github.io/dmenv/
11 stars 4 forks source link

dmenv tidy does not work from inside a virtualenv #110

Closed dmerejkowsky closed 5 years ago

dmerejkowsky commented 5 years ago

Here's what happens:

$ dmenv install
$ source $(dmenv show:venv_path)/bin/activate
$ dmenv tidy
Cleaning virtualenv ...
Recreate virtualenv ...
Error: /path/to/venv/python does not exist

The problem is that we read PythonInfo only once, and that info becomes obsolete between the clean and the virtualenv recreation...

impl Project {
    pub new(python_info: PythonInfo) -> Self {
      // ...
    } 

pub fn tidy(&self) -> Result<(), Error> {
        self.clean_venv()?;
        // Data in self.python_info is now out of date!
        self.create_venv()?;
   }
}