Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 havevirtualenvs.in-project
set totrue
. 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 apoetry.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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latter affords expansion later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?poetry.toml
exists in the project root.poetry.toml
containsin-project = true
in 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 runningpoetry env remove .venv
?