[WIP] fix poetry env remove does not work with in-project = true#2925
Conversation
…try env remove 2908
| base_env_name = self.generate_env_name(self._poetry.package.name, str(cwd)) | ||
|
|
||
| if python.startswith(base_env_name): | ||
| if python.startswith(base_env_name) or python == ".venv": |
There was a problem hiding this comment.
We shouldn't really do this if the environment was not created by us. There needs to be some flag somewhere (maybe even a marker file) in the env directory to determine if we created it.
There was a problem hiding this comment.
How about checking self._poetry.config.get("virtualenvs.in-project") is true, similar to what's done when listing the envs?
There was a problem hiding this comment.
The issue is that poetry supports existing environments. So, in cases where, lets say, someone needs some wierd system lib available etc., they might create .venv manually and also have virtualenvs.in-project set to true. In this scenario, there is no guarentee that we created it. Obviously other simpler scenarios exists too. Just picked an obtuse one.
There was a problem hiding this comment.
Does a marker file / flag like you say exist somewhere already or will that need to be added when Poetry creates a .venv?
There was a problem hiding this comment.
At the moment no. If we need to support this cleanly we should add one and add a good message if one is not found when user tries to delete this.
Virtualenv already creates a pyvenv.cfg, either relying on that or placing a poetry.toml file in the environment root maybe sufficient. Not sure what is the better approach here at the moment.
There was a problem hiding this comment.
The latter affords expansion later.
There was a problem hiding this comment.
So for a workaround (other than rm as noted in the initial issue) until #2924 (presumably?) changes the approach for a .venv would the following be sufficient?
- Check
poetry.tomlexists in the project root. - Check
poetry.tomlcontainsin-project = truein the appropriate place.
Would a situation exist where a user has set locally in-project = true but has manually created .venv and doesn't want to remove it when running poetry env remove .venv?
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
#2908
Fixing issue where a
poetry env remove .venvfails in a project withvirtualenvs.in-project = trueinpoetry.toml(so the virtualenv is stored in.venv).Pull Request Check List
Resolves: #issue-number-here