I am having a very bad case of “works on my machine” today. I am using a private GitLab repository and a package from a private package registry on the same GitLab instance.
On my machine, I have configured the package source with a personal access token.
This is my pyproject.toml. (I have obfuscated the naming, but you get the idea.)
[tool.poetry]
name = "my-project-name"
version = "0.0.1"
description = ""
authors = ["Eleanor <[email protected]>"]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.9"
[tool.poetry.group.dev.dependencies]
mypy = "^1.10.1"
pytest = "^8.2.2"
pycodestyle = "^2.12.0"
coverage = "^7.6.0"
pytest-html = "^4.1.1"
boto3-stubs = {extras = ["s3"], version = "^1.34.144"}
boto3 = "^1.34.144"
my-private-package = {version = "^0.0.8", source = "my-private-package-source"}
[[tool.poetry.source]]
name = "my-private-package-source"
url = "https://gitlab.private.gitlab.instance/api/v4/projects/9972/packages/pypi/simple"
priority = "explicit"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
I know that source url works because I can effectively query it by getting doing a
poetry add --group dev --source my-private-package-source my-private-package@latest
on my machine and the command succeeds.
The relevant portion of my .gitlab-ci.yml is as follows:
.poetry_setup:
script:
- !reference [.py_setup, script]
- $pycommand -m pip install pipx
- pipx_command="$pycommand -m pipx"
- poetry_command="$pipx_command run poetry"
- $poetry_command --version
- !reference [.poetry_setup_sources, script]
- $poetry_command install
.poetry_setup_sources:
script:
- $poetry_command config http-basic.my-private-package-source gitlab-ci-token $CI_JOB_TOKEN
- $poetry_command config certificates.my-private-package-source.cert /cfs-certs.pem
When I run this GitLab pipeline, I the job fails on the $poetry_command install
with the following error
- Installing my-private-package (0.0.8)
- Installing mypy (1.11.0)
- Installing pytest-html (4.1.1)
- Installing pycodestyle (2.12.0)
RuntimeError
Unable to find installation candidates for my-private-package (0.0.8)
at ~/.cache/pipx/d2080b0cb8a1427/lib/python3.9/site-packages/poetry/installation/chooser.py:74 in choose_for
70│
71│ links.append(link)
72│
73│ if not links:
→ 74│ raise RuntimeError(f"Unable to find installation candidates for {package}")
75│
76│ # Get the best link
77│ chosen = max(links, key=lambda link: self._sort_key(package, link))
78│
Cannot install my-private-package.
To debug, I made a change to the pipeline by switching out the $CI_JOB_TOKEN in the source configuration line to “nonsense”, and I got an authentication error. What this tells me is that when the package source is configured correctly as I understand it, poetry does query the correct endpoint and is able to authenticate successfully.
So I’m stumped.
What do you think is going on here? Or what possible debugging next steps should I take?