|
We recently updated our CI to use Poetry 2.4.1 and noticed a different behavior when it creates it's venv. Previously Poetry was smart about selecting a compatible Python version when we didn't run Now with 2.4.1 and most likely caused by this change (#10685) Poetry will happily run Question: Some more information OS - Amazon Linux 2023 Extract from Before updating to 2.4.1 After updating to 2.4.1 Shortened output of initial Output of subsequent |
Replies: 4 comments 3 replies
|
This may be an unintended side effect. #10685 only aimed to fix the issue that However, I cannot reproduce your issue. I get the following warning the first time and in subsequent runs (if I have not run Have you run |
|
No, you do not have to run With The later CI failure is from an existing 3.9 Pin in CI, and drop a cached bad env first if needed: rm -rf .venv
poetry env use 3.13
poetry installAlso check |
|
It is worth separating two things here, because one of them is working as documented and the other one is the actual bug. What
|
|
Your first question is a fair objection, and checking it properly shows I got part of my answer wrong. Correcting that first, because it changes the advice. Auto-selection is not goneI said it was never a documented contract and left the impression it had been removed. It has not been. It is still in specific_python_requested = python is not None
if not python:
python = Python.get_preferred_python(config=self._poetry.config, io=self._io)
...
if not supported_python.allows(python.patch_version):
if specific_python_requested:
raise NoCompatiblePythonVersionFoundError(...)
self._io.write_error_line(
f"The currently activated Python version ... is not supported by the project ...\n"
"Trying to find and use a compatible version."
)
python = Python.get_compatible_python(poetry=self._poetry, io=self._io)Verified on 2.5.0.dev0 with a project requiring a version I do not have installed, on a clean tree: $ poetry install
The currently activated Python version 3.14.4 is not supported by the project (>=3.15,<4.0).
Trying to find and use a compatible version.
Poetry was unable to find a compatible version. ...It searched. #10685 only tightened the explicit path — So none of my three fixes should be necessaryWhat actually stops the search is an environment that already exists. A few lines earlier: if (env.is_venv() and not force) or not create_venv:
current_python = Version.parse(...)
if not supported_python.allows(current_python):
raise InvalidCurrentPythonVersionError(
..., note='Please change python executable via the "env use" command.'
)
return envThat returns before auto-selection is ever reached. Same project, same Poetry, only difference being a $ python3 -m venv .venv && poetry install
Current Python version (3.14.4) is not allowed by the project (>=3.15,<4.0).
Please change python executable via the "env use" command.That is your subsequent-run error, and it is the message telling you to pin — not a sign that you have to. So the thing to fix in CI is the stale environment, not the interpreter selection: make sure the job does not carry a Keeping On the bug, and on not having time to write it upI tried to reproduce the part you described — One thing would settle it, and it is a copy-paste rather than an investigation. On the CI job, before anything else: rm -rf .venv
poetry config --list | grep -E 'virtualenvs\.(create|in-project|use-poetry-python|path)'
poetry install 2>&1 | head -20The question is whether that first install prints Paste that output here and I will write the ticket up properly, with the reproduction and the code paths. You should not have to spend an afternoon on it to report something you already found. |
It is worth separating two things here, because one of them is working as documented and the other one is the actual bug.
What
use-poetry-python = falseactually promisesFrom the configuration docs:
Note what that says and what it does not. It says the activated interpreter. It does not say a compatible interpreter, and it never promised to go looking for one. On your Amazon Linux 2023 box the activated interpreter is 3.9, so with
use-poetry-python = falsethat is what Poetry is told to use — regardless of whatrequire…