Deactivating poetry shell in direnv
It’s already mentioned in the docs about how to use poetry
with direnv
. But what is not mentioned is how do you deactivate poetry once this is set.
Well that’s not a frequent enough usecase but I have a globally installed tool called imgp
which uses the global python(which in my case is installed via asdf
). So now when I try to execute imgp
inside the direnv’d directory I get PIL
(a rqd. package for imgp
) is missing because we in the virtual env.
Now this is a adhoc thing, I want to optimize a bunch of images and then I can come back. I googled a bit but did not find a solution, What worked.
set -e POETRY_ACTIVE
set -e VIRTUAL_ENV
# now this will unset the variables set by direnv related to poetry
# but imgp still won't be able to access the correct env.
poetry shell
deactivate
# after the above two commands, something gets reset and now I am finally falling back on the global python
# yay!
now when I want my virual env back, I just go in and out of my project root and direnv takes care of setting up the appropriate environment for me.