python-poetry / python-poetry/poetry-plugin-shell
Poetry does not automatically switch venvs in venv-activated shells
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 141
- Forks
- 10
- Avg merge
- 59m
- Merged PRs (30d)
- 3
Description
- I am on the latest Poetry version.
- I have searched the issues of this repo and believe that this is not a duplicate.
- If an exception occurs when executing a command, I executed it again in debug mode (
-vvvoption).
- OS version and name: Ubuntu 20.04.2 LTS
- Poetry version: 1.1.16
Issue
Create two blank projects
/t/test> poetry new a
Created package a in a
/t/test> poetry new b
Created package b in b
/t/test> cd a
Create a's venv
/t/t/a> poetry shell
Creating virtualenv a-sARTaVSs-py3.8 in ~/.cache/pypoetry/virtualenvs
Spawning shell within ~/.cache/pypoetry/virtualenvs/a-sARTaVSs-py3.8
source ~/.cache/pypoetry/virtualenvs/a-sARTaVSs-py3.8/bin/activate.fish
Welcome to fish, the friendly interactive shell
Type `help` for instructions on how to use fish
(a-sARTaVSs-py3.8) /t/t/a> exit
We quitted a's venv, now create b's
/t/t/a> cd ../b
/t/t/b> poetry shell
Creating virtualenv b-Eo6UuKir-py3.8 in ~/.cache/pypoetry/virtualenvs
Spawning shell within ~/.cache/pypoetry/virtualenvs/b-Eo6UuKir-py3.8
source ~/.cache/pypoetry/virtualenvs/b-Eo6UuKir-py3.8/bin/activate.fish
Welcome to fish, the friendly interactive shell
Type `help` for instructions on how to use fish
We're still in b's venv, now let's go to a's project
(b-Eo6UuKir-py3.8) /t/t/b> cd ../a
(b-Eo6UuKir-py3.8) /t/t/a> poetry env info
Virtualenv
Python: 3.8.5
Implementation: CPython
Path: ~/.cache/pypoetry/virtualenvs/b-Eo6UuKir-py3.8
Valid: True
System
Platform: linux
OS: posix
Python: /usr
Crap, we are still in b's venv... If we run poetry install we'll install a's dependencies in b's venv
But there is a way out, eventhough the prompt is wrong (should be a-sARTaVSs-py3.8)
(b-Eo6UuKir-py3.8) /t/t/a> poetry env use python
Using virtualenv: ~/.cache/pypoetry/virtualenvs/a-sARTaVSs-py3.8
(b-Eo6UuKir-py3.8) /t/t/a> poetry env info
Virtualenv
Python: 3.8.5
Implementation: CPython
Path: ~/.cache/pypoetry/virtualenvs/a-sARTaVSs-py3.8
Valid: True
System
Platform: linux
OS: posix
Python: /usr
Now we are in a's venv (the right one), let's go back to b's project folder
(b-Eo6UuKir-py3.8) /t/t/a> cd ../b
(b-Eo6UuKir-py3.8) /t/t/b> poetry env info
Virtualenv
Python: 3.8.5
Implementation: CPython
Path: ~/.cache/pypoetry/virtualenvs/b-Eo6UuKir-py3.8
Valid: True
System
Platform: linux
OS: posix
Python: /usr
Surprisingly, on the way back everything is alright
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported flow with poetry shell, cd between the two projects, and poetry env info in a fish shell on Ubuntu. The change is done when moving between projects automatically selects the matching virtual environment and the shell prompt reflects it, without requiring poetry env use python.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fish, python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100