poetry: Error: Unable to store the password for poetry-repository-pypi in the key ring: Failed to unlock the collection!
Hi, I am getting [KeyRingError] Unable to store the password for poetry-repository-pypi in the key ring: Failed to unlock the collection!
when running:
poetry config pypi-token.pypi <MY PYPI TOKEN>
Searched for this error everywhere but couldn’t find anything. Running on the last version of Poetry and Ubuntu 18.04 LTS.
Also, if I set the token using an environment variable I get: Unable to retrieve the password for poetry-repository-pypi from the key ring
.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 31
- Comments: 29 (4 by maintainers)
OK keyringerror again. Then fixed it by
keyring --disable
in terminal on Ubuntu. Thenpoetry publish --build
as usual OK!I have a Mac, and I needed to delete an old password in the Keychain in order to get it to work. I went to the
Keychain Access
app, navigated to thelogin
default keychain and filtered onPasswords
. In there was one calledpoetry-repositor-***
, where***
was my private repo. Deleting that and runningpoetry config http-basic.<PRIVATE-REPO> <USER> <TOKEN>
again solved this issue for me.Had the same problem in a container, solved it by setting the null keyring within the underlying lib, it’s just an env variable:
see https://pypi.org/project/keyring/ disabling keyring
this fixed it for me… https://blog.frank-mich.com/python-poetry-1-0-0-private-repo-issue-fix/
Poetry strikes again 💣
Why does poetry need the keyring? Is it possible to build/deploy in CI/CD without using a keyring?
I’m running into a similar error with Poetry v1.2.0 for simple operations like installing a plugin in my Debian development environment. I’m not sure whether this is exactly the same issue as described above or just results in a similar error message.
This seems to have happened because I was SSH’d into my development environment, which has the GNOME Keyring installed. When I RDP’d in so I would have an X session, then the GNOME keyring dialog popped up to unlock the keyring. On the surface, it doesn’t seem like there’s any need for the keyring in this situation, because I’m installing a public plugin. It seems like maybe there’s a code path where Poetry attempts to unlock the keyring even if it’s not going to be needed.
I don’t get this error on Windows or MacOS, although it’s possible that a keyring is just silently being unlocked under the covers on those platforms, and I don’t notice because it’s not failing.
My workaround is to explicitly set a null keyring as suggested in @Cardu 's comment above, in Poetry issue #6277, and also in pip issue #6773:
I also confirmed that
keyring --disable
works as in @KafCoppelia 's suggestion. However, I don’t like that solution for my use case, because it permanently disables the keyring in configuration, and I do need the keyring available for other things.This, but is not cool to have to install something of
gnome
if you are not usinggnome
…well, maybe a permission problem, with “sudo” save me in this case
This, easiest solution and worked perfectly
Just to add to the macos solutions above: the Issue for me was that the key is added to the keychain with access only allowed by a specific python version. When I switched python versions then the poetry config command started failing. The solution is to allow all apps on the poetry keys or add the additional python versions you need. Ideally poetry would handle this or at least provide a better error message.
Also happens to me when connecting via SSH, and my workaround is to disable
keyring
within a sufficient scope, aspoetry
can work withoutkeyring
.My two cents are that this behaviour is not consistent with the docs. The documentation promises a backup in case of
keyring
failure:Of course, it may well be an issue on the keyring side (locked, not set up properly…), but would be nice to fall back gracefully. A bit odd, but sometimes poetry depends on
keyring
even for password-free operations in config:EDIT: the keyring usage is handled in
poetry.utils.password_manager
and has improved a bit since in version1.2
, in particular with respect to null backends.https://github.com/python-poetry/poetry/blob/0686427ce175e14b69c8ffeca4515cce79453047/src/poetry/utils/password_manager.py#L109-L141
right, but why bother storing credentials? i don’t want it to.
POETRY_PYPI_TOKEN_PYPI
to a valid token… didn’t help… still wants my keyring~/.pypirc
like twine does…poetry config
and its sundry ways could be mentioned in the error messages?@earonesty
poetry
useskeyring
for storing credentials. It is entirely possible to build/deploy in CI/CD without any issues.https://github.com/python-poetry/poetry/blob/17b165bf8c8d989d672417fd4610721df59ae1d0/.github/workflows/release.yml#L261-L266
I’m quite curious about this as well actually.
https://github.com/python-poetry/poetry/issues/2692#issuecomment-996489094
I can’t remember ever having to install any package with root permissions. Infact, If I remember correctly, pip specifically warns against it.
Also, why exactly does poetry modify the error Traceback?
sigh I have other questions, but mainly why does poetry even request access from the keyring in the first place?
sudo pacman -S gnome-keyring
solved it for me.Oh fixed it today by using
poetry config http-basic.pypi username password
.Similar error occured when I was using
poetry build
thenpoetry publish
to publish my python project to PYPI.🤔 But yesterday before the problem ocurred Poetry did in normal.KeyRingError
Unable to retrieve the password for poetry-repository-pypi from the key ring
at ~/.local/share/pypoetry/venv/lib/python3.8/site-packages/poetry/utils/password_manager.py:39 in get_password 35│ 36│ try: 37│ return keyring.get_password(name, username) 38│ except (RuntimeError, keyring.errors.KeyringError): → 39│ raise KeyRingError( 40│ “Unable to retrieve the password for {} from the key ring”.format(name) 41│ ) 42│ 43│ def set_password(self, name, username, password):