hatch
hatch copied to clipboard
NoKeyringError: No recommended backend was available
I'm getting an error when trying to publish, right after typing the username.
$ hatch publish
Enter your username: example.username
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/user/Workspace/basketcase/venv/lib/python3.10/site-packages/hatch/cli/__init__.py:203 in │
│ main │
│ │
│ 200 │
│ 201 def main(): # no cov │
│ 202 │ try: │
│ ❱ 203 │ │ return hatch(windows_expand_args=False) │
│ 204 │ except Exception: │
│ 205 │ │ from rich.console import Console │
│ 206 │
│ │
│ /home/user/Workspace/basketcase/venv/lib/python3.10/site-packages/click/core.py:1130 in │
│ __call__ │
│ │
│ /home/user/Workspace/basketcase/venv/lib/python3.10/site-packages/click/core.py:1055 in main │
│ │
│ /home/user/Workspace/basketcase/venv/lib/python3.10/site-packages/click/core.py:1657 in invoke │
│ │
│ /home/user/Workspace/basketcase/venv/lib/python3.10/site-packages/click/core.py:1404 in invoke │
│ │
│ /home/user/Workspace/basketcase/venv/lib/python3.10/site-packages/click/core.py:760 in invoke │
│ │
│ /home/user/Workspace/basketcase/venv/lib/python3.10/site-packages/click/decorators.py:38 in │
│ new_func │
│ │
│ /home/user/Workspace/basketcase/venv/lib/python3.10/site-packages/hatch/cli/publish/__init__.p │
│ y:77 in publish │
│ │
│ 74 │ if publisher.disable and not (yes or (not no_prompt and app.confirm(f'Confirm `{publ │
│ 75 │ │ app.abort(f'Publisher is disabled: {publisher_name}') │
│ 76 │ │
│ ❱ 77 │ publisher.publish(list(artifacts), option_map) │
│ 78 │
│ │
│ /home/user/Workspace/basketcase/venv/lib/python3.10/site-packages/hatch/publish/index.py:81 in │
│ publish │
│ │
│ 78 │ │ │ if not auth: │
│ 79 │ │ │ │ import keyring │
│ 80 │ │ │ │ │
│ ❱ 81 │ │ │ │ auth = keyring.get_password(repo, user) │
│ 82 │ │ │ │ if auth is None: │
│ 83 │ │ │ │ │ if options['no_prompt']: │
│ 84 │ │ │ │ │ │ self.app.abort('Missing required option: auth') │
│ │
│ /home/user/Workspace/basketcase/venv/lib/python3.10/site-packages/keyring/core.py:55 in │
│ get_password │
│ │
│ 52 │
│ 53 def get_password(service_name: str, username: str) -> typing.Optional[str]: │
│ 54 │ """Get password from the specified service.""" │
│ ❱ 55 │ return get_keyring().get_password(service_name, username) │
│ 56 │
│ 57 │
│ 58 def set_password(service_name: str, username: str, password: str) -> None: │
│ │
│ /home/user/Workspace/basketcase/venv/lib/python3.10/site-packages/keyring/backends/fail.py:25 │
│ in get_password │
│ │
│ 22 │ │ │ "you want to use the non-recommended backends. See " │
│ 23 │ │ │ "https://pypi.org/project/keyring for details." │
│ 24 │ │ ) │
│ ❱ 25 │ │ raise NoKeyringError(msg) │
│ 26 │ │
│ 27 │ set_password = delete_password = get_password # type: ignore │
│ 28 │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
NoKeyringError: No recommended backend was available. Install a recommended 3rd party backend package; or, install the
keyrings.alt package if you want to use the non-recommended backends. See https://pypi.org/project/keyring for details.
I'm on Kubuntu 22.04. I've seen in other similar reports that this command is used to check if the KWallet backend is working, so here it is:
$ python3 -c "from keyring.backends.kwallet import DBusKeyring; print(DBusKeyring.priority)"
5.1
This is the project repository: https://gitlab.com/crimson.king/basketcase/-/tree/82c3489d3150cda376f6c3b55a06b5fae129505b
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "basketcase"
version = "3.1.0"
authors = []
description = ""
readme = "README.md"
license = { file="LICENSE" }
requires-python = ">=3.8"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
dependencies = [
"requests~=2.28.1",
"yt-dlp==2022.10.4",
"Pillow~=9.3.0",
]
[project.scripts]
"basketcase" = "basketcase.__main__:main"
[project.urls]
"Homepage" = "https://gitlab.com/crimson.king/basketcase"
"Bug Tracker" = "https://gitlab.com/crimson.king/basketcase/-/issues"
My workaround is using twine upload dist/*
to publish. It works.
Have you tried this? https://github.com/jaraco/keyring#using-keyring-on-ubuntu-1604
I think I have the same issue on Debian.
Would it be possible to add an option that disables keyring
usage altogether and simply prompts for user/password every time I run hatch publish
?
I've wasted the last few hours trying to get keyring
working and I'm giving up now. I already have a secret manager that is much, much simpler and I don't need another one.
I hit this error too (I mount /proc
with hidepid=2
for extra security)
as @plotski suggests - an option to disable keyring
functionality entirely would solve this - or perhaps a more user friendly way would be to prompt the user to enable / use keyring
functionality when the processing starts (& not automatically assume it is available)
this processing could also possibly run inside a ci/cd container or other restricted environment - so a specific command line switch to disable keyring
functionality is useful for non interactive usage
for the time being as mentioned above twine upload dist/*
is a workaround - twine
hits the same keyring
error - but does not crash out entirely when hitting this issue.
On a more positive note - the colourful stack trace was nice ;o)
Please make keyring optional, or have the provided "unsafe" workaround (installing keyrings.alt
) work. It currently doesn't, and I have to fallback to twine. I am not interested in setting up any keyring daemon, on some of the machines I work on.
I'd also like to see keyring support disabled. I am running alpine linux using a relatively barebones setup of tmux directly in the linux console. I don't want to setup any keyring service simply to pass in an API token to publish my packages.