python-poetry/poetry · error · PoetryKeyringError
Unable to store the password for {name} in the key ring: {e}
Error message
Unable to store the password for {name} in the key ring: {e} What it means
PoetryKeyring.set_password wraps keyring.set_password and, on RuntimeError or keyring.errors.KeyringError, raises PoetryKeyringError with the underlying exception. The credential could not be persisted to the OS/secret-service backend.
Source
Thrown at src/poetry/utils/password_manager.py:120
name = self.get_entry_name(name)
try:
return keyring.get_password(name, username or self._EMPTY_USERNAME_KEY)
except (RuntimeError, keyring.errors.KeyringError) as e:
raise PoetryKeyringError(
f"Unable to retrieve the password for {name} from the key ring {e}"
)
def set_password(self, name: str, username: str, password: str) -> None:
import keyring
import keyring.errors
name = self.get_entry_name(name)
try:
keyring.set_password(name, username or self._EMPTY_USERNAME_KEY, password)
except (RuntimeError, keyring.errors.KeyringError) as e:
raise PoetryKeyringError(
f"Unable to store the password for {name} in the key ring: {e}"
)
def delete_password(self, name: str, username: str) -> None:
import keyring.errors
name = self.get_entry_name(name)
try:
keyring.delete_password(name, username or self._EMPTY_USERNAME_KEY)
except (RuntimeError, keyring.errors.KeyringError):
raise PoetryKeyringError(
f"Unable to delete the password for {name} from the key ring"
)
def get_entry_name(self, name: str) -> str:
return f"{self._namespace}-{name}"
View on GitHub (pinned to 92b74dcfe3)
Solutions
- Unlock the keyring/keychain and verify the Secret Service collection is writable.
- Disable keyring in headless environments (`poetry config keyring.enabled false`) and store tokens in config/env.
- Restart the keyring daemon and retry.
- Check disk space and permissions on the keyring storage.
Example fix
# before poetry config pypi-token.pypi pypi-xxxx # set_password fails on locked keyring # after poetry config keyring.enabled false poetry config pypi-token.pypi pypi-xxxx
Defensive patterns
Strategy: try-catch
Validate before calling
from poetry.utils.password_manager import PoetryKeyring
if not PoetryKeyring.is_available():
raise RuntimeError('keyring unavailable; disable keyring.enabled or use config') Try / catch
from poetry.utils.password_manager import PoetryKeyringError
try:
manager.keyring.set_password(name, username, password)
except PoetryKeyringError:
# store via config/env as a fallback
manager._config.auth_config_source.add_property(['pypi-token', name], password) Prevention
- Ensure the Secret Service collection is unlocked and writable before saving.
- Disable keyring.enabled on hosts where no backend is available.
- Restart the keyring daemon if saves start failing.
When it happens
Trigger: Storing a repository password or PyPI token via the keyring when the backend rejects the write: keyring locked, disk full, D-Bus failure, permission denied on the Secret Service collection.
Common situations: Locked keychain on first credential save; headless server without an unlocked Secret Service; read-only keyring backend; keyring daemon not running.
Related errors
- Unable to retrieve the password for {name} from the key ring
- Unable to delete the password for {name} from the key ring
- Access to keyring was requested, but it is not available
- HTTP Error {e.response.status_code}: {e.response.reason} | {
- <error>Failed to clone <info>{url}</>, check your git config
AI-assisted analysis of python-poetry/poetry@92b74dcfe3 (2026-08-04).
Data as JSON: /data/errors/84c571bc4757f3f9.json.
Report an issue: GitHub.