-vvv option).Ubuntu 18.04 bionicPoetry version 1.0.10N/AStarting with 1.1.0 of Poetry poetry install is failing for some of our private packages:
$ poetry install --no-interaction --no-ansi
Creating virtualenv project-name-nxCwz_m9-py3.8 in /builds/REDACTED/.cache/poetry/virtualenvs
Installing dependencies from lock file
Warning: The lock file is not up to date with the latest changes in pyproject.toml. You may be getting outdated dependencies. Run update to update them.
Package operations: 85 installs, 0 updates, 0 removals
โข Installing six (1.15.0)
<SNIP>
โข Installing private-package-1 (0.2.1)
RuntimeError
Unable to find installation candidates for private-package-1 (0.2.1)
at /usr/local/lib/python3.8/site-packages/poetry/installation/chooser.py:72 in choose_for
68โ
69โ links.append(link)
70โ
71โ if not links:
โ 72โ raise RuntimeError(
73โ "Unable to find installation candidates for {}".format(package)
74โ )
75โ
76โ # Get the best link
โข Installing flake8-print (3.1.4)
โข Installing hypothesis (5.26.0)
โข Installing isort (4.3.21)
โข Installing jsonschema (3.2.0)
โข Installing mock (4.0.2)
โข Installing mypy (0.780)
โข Installing networkx (2.4)
โข Installing pytest-cov (2.10.1)
โข Installing private-package-2 (0.1.6)
RuntimeError
Unable to find installation candidates for private-package-2 (0.1.6)
at /usr/local/lib/python3.8/site-packages/poetry/installation/chooser.py:72 in choose_for
68โ
69โ links.append(link)
70โ
71โ if not links:
โ 72โ raise RuntimeError(
73โ "Unable to find installation candidates for {}".format(package)
74โ )
75โ
76โ # Get the best link
โข Installing pyyaml (5.3.1)
โข Installing seed-isort-config (2.2.0)
โข Installing sentry-sdk (0.17.3)
โข Installing tabulate (0.8.7)
โข Installing taskipy (1.3.0)
โข Installing vulture (1.6)
โข Installing xlrd (1.2.0)
Note, it returns non-zero but other than the error in the middle of the install it doesn't actually have a specific message.
After playing around a bit with poetry update I discovered that adding type = "legacy" to the poetry.lock for those packages fixes this.
diff --git a/project-name/poetry.lock b/project-name/poetry.lock
index ece9221..83d5f84 100644
--- a/project-name/poetry.lock
+++ b/project-name/poetry.lock
@@ -446,6 +446,7 @@ snappy = ["python-snappy (>=0.5.4,<0.6.0)"]
[package.source]
reference = "gitlabprivate"
+type = "legacy"
url = "https://gitlab.com/api/v4/projects/REDACTED/packages/pypi/simple"
[[package]]
@@ -921,6 +922,7 @@ python-json-logger = ">=0.1.11,<0.2.0"
[package.source]
reference = "gitlabprivate"
+type = "legacy"
url = "https://gitlab.com/api/v4/projects/REDACTED/packages/pypi/simple"
[[package]]
Based on this part of the blogpost[1] that suggests 1.1.0 should be able to read previous versions but not vice versa, this is likely unintended.
[1] https://python-poetry.org/blog/announcing-poetry-1-1-0.html#lock-file-format-changes
Can confirm. Legacy users need to run poetry update to add these keys to the older sources.
Our team just hit this issue, which breaks docker builds where the poetry version is not pinned. A short-term workaround that fixed our builds is to pin the poetry version (pip install poetry==1.0.5) prior to running poetry install.
Our team just hit this issue, which breaks docker builds where the poetry version is not pinned. A short-term workaround that fixed our builds is to pin the poetry version (
pip install poetry==1.0.5) prior to runningpoetry install.
Thanks! I was also struggling with this issue today(remote run fails).
@xM8WVqaG poetry lock should resolve your issue, this is because the lock file now correctly adds package source information.
I have also added #3034 to add a feature that adds poetry lock --no-update that will allow users to refresh the lock file without updating pinned dependencies. Feel free to test that branch.
@abn Thanks for the follow up to this but I have attempted poetry lock --no-update as suggested using poetry from the master branch and it didn't add the necessary information to poetry.lock to fix the poetry install.
All poetry lock --no-update did to the relevant section of of poetry.lock is:
[package.source]
-reference = "gitlabprivate"
url = "https://gitlab.com/api/v4/projects/REDACTED/packages/pypi/simple"
+reference = "gitlabprivate"
It still fails with the same error:
$ poetry install
<snip>
โข Installing private-package-2 (0.1.6): Failed
RuntimeError
Unable to find installation candidates for private-package-2 (0.1.6)
at /REDACTED/venv/lib/python3.8/site-packages/poetry/installation/chooser.py:72 in choose_for
68โ
69โ links.append(link)
70โ
71โ if not links:
โ 72โ raise RuntimeError(
73โ "Unable to find installation candidates for {}".format(package)
74โ )
75โ
76โ # Get the best link
I can confirm that MR #3051 (from #3048) fixes the lock --no-update failing to update the source block.
[package.source]
-reference = "gitlabprivate"
+type = "legacy"
url = "https://gitlab.com/api/v4/projects/REDACTED/packages/pypi/simple"
+reference = "gitlabprivate"
I'm still having this issue on and off. I have tried updating my lock file using:
poetry lockpoetry lock --no-updatepoetry updateI can confirm that type = "legacy" exists in poetry.lock, however when I run poetry install with a clean environment i get the error:
$ poetry install
<snip>
โข Installing XXX (1.0.0): Failed
RuntimeError
Unable to find installation candidates for XXX (1.0.0)
at progs/poetry/lib/poetry/installation/chooser.py:72 in choose_for
68โ
69โ links.append(link)
70โ
71โ if not links:
โ 72โ raise RuntimeError(
73โ "Unable to find installation candidates for {}".format(package)
74โ )
75โ
76โ # Get the best link
If i rerun poetry install a second time, it sometimes will work fine. Sometimes a third run is required. However it always fails for the first run, but will pass at some point on subsequent runs. THis is fine on my local machine but is causing havoc on my CI runs and install always fails.
Any ideas as to why this would happen?
Most helpful comment
I'm still having this issue on and off. I have tried updating my lock file using:
poetry lockpoetry lock --no-updatepoetry updateI can confirm that
type = "legacy"exists in poetry.lock, however when I runpoetry installwith a clean environment i get the error:If i rerun poetry install a second time, it sometimes will work fine. Sometimes a third run is required. However it always fails for the first run, but will pass at some point on subsequent runs. THis is fine on my local machine but is causing havoc on my CI runs and install always fails.
Any ideas as to why this would happen?