Poetry Hangs or Fails on keyring in CI - Disable the Backend
On a headless runner, Poetry’s use of the keyring library tries to reach a system secret service that does not exist, so credential lookups error or hang. Disabling keyring makes Poetry read tokens from env/config instead.
What this error means
A poetry install/publish step errors with a keyring/SecretStorage failure (Failed to create the collection: Prompt dismissed), or silently hangs waiting on a D-Bus secret service. It only happens on CI where no desktop keyring is running.
[keyring.errors.KeyringError]
Failed to create the collection: Prompt dismissed..
# or the job hangs on:
keyring.backends.SecretService ...Common causes
No keyring service on a headless runner
The keyring library defaults to a desktop secret service (SecretStorage/D-Bus, macOS Keychain). CI has none, so the backend errors or blocks.
Poetry tries keyring before env/config credentials
Unless told otherwise, Poetry consults keyring for index credentials, hitting the missing backend before falling back.
How to fix it
Disable keyring for the job
Point keyring at the null backend so Poetry uses env vars/config instead of a system service.
export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
poetry config http-basic.pypi __token__ "$PYPI_TOKEN"
poetry installProvide credentials via environment variables
Poetry reads index credentials from POETRY_HTTP_BASIC_* / POETRY_PYPI_TOKEN_*, avoiding keyring entirely.
export POETRY_PYPI_TOKEN_PYPI="$PYPI_TOKEN"
# or for a named source "internal":
export POETRY_HTTP_BASIC_INTERNAL_USERNAME=__token__
export POETRY_HTTP_BASIC_INTERNAL_PASSWORD="$INTERNAL_TOKEN"How to prevent it
- Set
PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyringon headless CI. - Pass index credentials through env vars, not a keyring.
- Keep credential config identical across local and CI to avoid surprises.