Open alissa-huskey opened 5 months ago
I've found that this seems to be caused by the VIRTUAL_ENV
environment variable. When you run poetry shell
(or I think any poetry command), it sets this variable. Unfortunately if you try to use the -C/--directory OTHER-PROJECT-PATH
option when this variable is set, the environment variable overrides the CLI option for choosing the virtualenv to use. i.e., if you add unset VIRTUAL_ENV
to the top of step-two.sh
, it works as expected.
IMO the correct behaviour here should be that path provided by the --directory
CLI option should have higher precedence than the VIRTUAL_ENV
environment variable when choosing the virtual environment to use.
I'm having similar issues - I'm tyring to write a python a script that cleans up my dev dir and tries to identify poetry venv paths - if I run poetry env info
using subprocess.run
and remove the VIRTUAL_ENV environment variable, poetry silently quits with exit code 1, if I don't, then it thinks the virtualenv is the "parent project's" venv.
Description
When you're inside of a
poetry shell
for one project and you runpoetry --directory OTHER-PROJECT-PATH ...
, the--directory
option is ignored.Steps to Reproduce
Convenience Scripts
step-one.sh
step-two.sh
reset.sh
Reproduce the Bug
Start Over
Workarounds
Exit the poetry shell before running
poetry --directory OTHER-PROJECT-PATH ...
(step-two.sh
).Poetry Installation Method
install.python-poetry.org
Operating System
Darwin 23.4.0 arm64
Poetry Version
Poetry (version 1.8.3)
Poetry Configuration