python-poetry / python-poetry/poetry
Poetry fails to activate virtual env if activated python version is not valid in pyprojec.toml
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 34.3k
- Forks
- 2.5k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 30
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 18
-
Poetry version: 1.15
I have a linux environment with two python versions installed (3.6, the default one since I'm using Ubuntu 18) and 3.7.
On my poetry environment I want to use python 3.7, so I have it listed like this:
[tool.poetry.dependencies]
python = "3.7.*"
If I run poetry install I get a warning about python 3.6 not being supported by the project, but poetry manages to find my python 3.7 install and it creates the env successfully.
The problem is that after that the environment is not listed as Activated:
$ poetry install
The currently activated Python version 3.6.9 is not supported by the project (3.7.*).
Trying to find and use a compatible version.
Using python3.7 (3.7.5)
Creating virtualenv bug-LMl0r2r8-py3.7 in /root/.cache/pypoetry/virtualenvs
Installing dependencies from lock file
Package operations: 25 installs, 0 updates, 0 removals
• Installing pyparsing (2.4.7)
• Installing certifi (2020.12.5)
• Installing chardet (4.0.0)
• Installing idna (2.10)
• Installing markupsafe (1.1.1)
• Installing packaging (20.9)
• Installing six (1.15.0)
• Installing urllib3 (1.25.11)
• Installing bottle (0.12.19)
• Installing colorama (0.4.4)
• Installing deprecation (2.0.7)
• Installing distro (1.5.0)
• Installing fasteners (0.16)
• Installing future (0.18.2)
• Installing jinja2 (2.11.3)
• Installing node-semver (0.6.1)
• Installing patch-ng (1.17.4)
• Installing pluginbase (1.0.0)
• Installing pygments (2.8.1)
• Installing pyjwt (1.7.1)
• Installing python-dateutil (2.8.1)
• Installing pyyaml (5.4.1)
• Installing requests (2.25.1)
• Installing tqdm (4.59.0)
• Installing conan (1.32.1)
$ poetry env info
Virtualenv
Python: 3.6.9
Implementation: CPython
Path: NA
System
Platform: linux
OS: posix
Python: /usr
$ poetry env list
bug-LMl0r2r8-py3.7
This means that poetry env info --path errors out (with no message), which breaks our pipeline.
If I do poetry env use 3.7 now the env gets activated and everything is back to normal
$ poetry env use 3.7
Using virtualenv: /root/.cache/pypoetry/virtualenvs/bug-LMl0r2r8-py3.7
$ poetry env list
bug-LMl0r2r8-py3.7 (Activated)
$ poetry env info --path
/root/.cache/pypoetry/virtualenvs/bug-LMl0r2r8-py3.7
If I use the default version of python on my pyproject.toml, the environments are marked as Activated automatically after creation.
I'll attach a dockerfile, the needed poetry fies and a README file with instructions
to reproduce it.
Thanks!
poetryBug.zip
Contributor guide
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 with the attached Dockerfile, Poetry files, and README to reproduce the environment-selection behavior using poetry install, poetry env info, and poetry env list. Trace why the compatible Python 3.7 environment is created but not marked as activated; done means poetry env list reports it as Activated and poetry env info --path returns its path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100