Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When keyring is disabled, poetry tries to use it anyways. #5250

Closed
3 tasks done
lakinwecker opened this issue Feb 28, 2022 · 26 comments · Fixed by #5251
Closed
3 tasks done

When keyring is disabled, poetry tries to use it anyways. #5250

lakinwecker opened this issue Feb 28, 2022 · 26 comments · Fixed by #5251
Labels
kind/bug Something isn't working as expected

Comments

@lakinwecker
Copy link
Contributor

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • Arch linux up to date:
  • 1.1.13:
  • Link of a Gist with the contents of your pyproject.toml file: pyproject.toml

Issue

If you disable keyring via it's recommended route: https://github.com/jaraco/keyring#disabling-keyring you end up with a "null" keyring being used. This is a useless keyring, but poetry continues to try and use it regardless. poetry should treat it the same as if keyring was unavailable.

@lakinwecker lakinwecker added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Feb 28, 2022
@lakinwecker
Copy link
Contributor Author

To be clear, when it fails this way, it fails to do things like it doesn't try and use the environment variable. It just silently ignores it.

@tyler-8
Copy link

tyler-8 commented Mar 10, 2022

To be clear, when it fails this way, it fails to do things like it doesn't try and use the environment variable. It just silently ignores it.

This is a key symptom. I've been very confused as to why my correctly set environment variables for username/password of a private repo are not working. It wasn't until I disabled the keyring (as apparently I'd configured poetry to use it in the past) that I realized that truly the envars were being bypassed. Instead I get prompted for the password when doing poetry publish -r myrepo.

# envars
POETRY_HTTP_BASIC_MYREPO_USERNAME=someuser
POETRY_HTTP_BASIC_MYREPO_PASSWORD=password

# poetry config --list

repositories.myrepo.url = "https://internalpypi.domain.com/pypi"

@kadler
Copy link

kadler commented Mar 14, 2022

I ran in to this same issue today. Looks like a similar check like this needs to be made for "null":

https://github.com/python-poetry/poetry/blob/master/src/poetry/utils/password_manager.py#L100-L102

@kadler
Copy link

kadler commented Mar 14, 2022

As a workaround, the "fail" backend can be used: export PYTHON_KEYRING_BACKEND=keyring.backends.fail.Keyring

@lakinwecker
Copy link
Contributor Author

I ran in to this same issue today. Looks like a similar check like this needs to be made for "null":

https://github.com/python-poetry/poetry/blob/master/src/poetry/utils/password_manager.py#L100-L102

Yes, that's what the associated pull request does. 👍 Just waiting on me to have the time to get the unit tests done and I don't know when that will happen.

@kadler
Copy link

kadler commented Mar 15, 2022

Oh sorry, I didn't see there was a PR already. Nice!

@epogrebnyak
Copy link

As a workaround, the "fail" backend can be used: export PYTHON_KEYRING_BACKEND=keyring.backends.fail.Keyring

This is genius, helped so much, thank you.

@mkniewallner mkniewallner removed the status/triage This issue needs to be triaged label Jun 11, 2022
a16su added a commit to a16su/registry_client that referenced this issue Oct 29, 2022
a16su added a commit to a16su/registry_client that referenced this issue Oct 29, 2022
@callamd
Copy link

callamd commented May 3, 2023

2023 and this issue still exists and is not fixed. :)

@lakinwecker
Copy link
Contributor Author

This issue was fixed with the #5251 and released sometime thereafter. I haven't run into the issue since that point. If you're running into something similar can you double check that you're using a recent enough version so that it includes the fix and if so, please submit details of how to reproduce it, rather than just claiming it still exists?

@maxbachmann
Copy link

I am running into this with 1.4.2 again as well. I just tried to run poetry lock in the cleo repository.

@lakinwecker
Copy link
Contributor Author

lakinwecker commented May 15, 2023

I can't reproduce it: https://gist.github.com/lakinwecker/e85279c2fece8bec211c3608567c4162

Do you have an environment variable for PYTHON_KEYRING_BACKEND set? I don't


cleo on  main is 📦 v2.1.0.dev0 via 🐍 v3.11.3 (cleo-py3.11) 
!->

@lakinwecker
Copy link
Contributor Author

Even with the keyring set, I can't reproduce it.

@aldum
Copy link

aldum commented May 20, 2023

Question: why is it trying to access a keyring when installing dependencies?

@ralbertazzi
Copy link
Contributor

#1917

Nebucatnetzer added a commit to Nebucatnetzer/network_inventory that referenced this issue Jun 25, 2023
I don't really need it at the moment and there is a bug with poetry.
python-poetry/poetry#5250
python-poetry/poetry#1917
@rdbisme
Copy link

rdbisme commented Oct 10, 2023

Question: why is it trying to access a keyring when installing dependencies?

Because sometimes you might want to access dependencies on an authenticated custom pypi registry?

@maciej-gol
Copy link

Question: why is it trying to access a keyring when installing dependencies?

Because sometimes you might want to access dependencies on an authenticated custom pypi registry?

It should be clear which dependencies it accesses the keyring for, though. Having a generic prompt to access my keyring by a package manager knowing that I don't use custom pypi registry triggers my safety bells.

@kierke-gaard
Copy link

Same problem on wsl2. This has helped (thanks for the advise):

export PYTHON_KEYRING_BACKEND=keyring.backends.fail.Keyring

@gbrandt1
Copy link

gbrandt1 commented Dec 3, 2023

still present in 1.7.1 :-(

@codethief
Copy link

codethief commented Feb 20, 2024

I just ran into this again and, once more, it took me a while to figure this out, since poetry add -vvv <package> just froze and didn't output anything useful. sigh

Can we please at least re-open this ticket and acknowledge this is an issue that needs fixing?

@radoering
Copy link
Member

There is #8623 and #8761. Do you think we need a third issue?

And there is #8910 (which will be included in 1.8). Apart from introducing a config setting to disable keyring, it refactored keyring access and thereby fixed some bugs.

@maciej-gol
Copy link

@radoering From my POV, this doesn't address my concerns, as I still believe keyring should be disabled by default and opt-in for users that actually need it. That solution no different than putting export PYTHON_KEYRING_BACKEND=keyring.backends.fail.Keyring into my .bashrc. But its a step into good direction, nonetheless.

@ManBearPigg
Copy link

There is #8623 and #8761. Do you think we need a third issue?

Prob because it breaks the whole project and the obscure fix is hard to find. I know it's free software I'm just saying why

@callamd
Copy link

callamd commented Feb 29, 2024 via email

@maciej-gol
Copy link

@cal97g nice try, 2/10. Missing tests.

@alanwilter
Copy link

alanwilter commented Mar 20, 2024

Why is this issue closed? Spent two days and two developers to figure this out, using v1.8.2.

poetry could be much smarter here. Could at least warn about it. This is another reason why we considering hatch again.

@radoering
Copy link
Member

It's closed because the original issue has been resolved in #5251.
(Poetry now respects PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring.)

As already mentioned, there are at least two open issues, which fit better for people still experiencing issues with keyring: #8623 and #8761

If you have useful information please comment on these issues or open a new issue if you think that your issue is not covered by them.

@python-poetry python-poetry locked as resolved and limited conversation to collaborators Mar 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.