python-poetry / python-poetry/poetry-plugin-shell
`poetry shell` and `poetry run` access different pip instances
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: macOS Big Sur 11.6.4 (20G417)
- Poetry version: 1.1.13
- Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/itcarroll/f46c6dbc6f53da88e7715f877be41452
Issue
I'm getting different pip instances depending on whether I use poetry run pip or start a new shell with poetry shell. The correct one is poetry run pip. The pip that poetry shell uses is wrong, and is not even at the path given by which pip. A clue might be that poetry shell has an extra environment variable also pointing to the wrong venv: __PYVENV_LAUNCHER__=/Users/icarroll/.local/pipx/venvs/poetry/bin/python.
Starting in an empty directory containing only pyproject.toml, here's what I'm seeing:
% poetry install
Creating virtualenv bug-report-f5FbZAGT-py3.8 in /Users/icarroll/Library/Caches/pypoetry/virtualenvs
Updating dependencies
Resolving dependencies... (0.1s)
Writing lock file
% poetry run pip --version
pip 22.0.3 from /Users/icarroll/Library/Caches/pypoetry/virtualenvs/bug-report-f5FbZAGT-py3.8/lib/python3.8/site-packages/pip (python 3.8)
% poetry shell
Spawning shell within /Users/icarroll/Library/Caches/pypoetry/virtualenvs/bug-report-f5FbZAGT-py3.8
Restored session: Tue Mar 8 18:54:56 EST 2022
% . /Users/icarroll/Library/Caches/pypoetry/virtualenvs/bug-report-f5FbZAGT-py3.8/bin/activate
(bug-report-f5FbZAGT-py3.8) % pip --version
pip 22.0.4 from /Users/icarroll/.local/pipx/shared/lib/python3.8/site-packages/pip (python 3.8)
(bug-report-f5FbZAGT-py3.8) % which pip
/Users/icarroll/Library/Caches/pypoetry/virtualenvs/bug-report-f5FbZAGT-py3.8/bin/pip
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
Reproduce the discrepancy from the issue's empty-directory setup using poetry install, poetry run pip --version, and poetry shell, then inspect the shell activation and environment-variable behavior described there. Done means pip inside the spawned shell resolves to the same virtual environment and pip instance as poetry run pip, including the reported which pip path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100