Check existing issues
Bug description
On a headless system, charmcraft login warns that it failed to obtain a keyring and that every store interaction will go through the web authentication process again:
$ charmcraft login
WARNING: Cannot get a keyring. Every store interaction that requires authentication will require you to log in again.Opening an authorization web page in your browser.
If it does not open, please open this URL:
https://api.jujucharms.com/identity/login?did=a6f....
If I try to switch to the python3-keyrings.alt package and the EncryptedFile keyring type, it also fails:
ubuntu@phased-updater-ops:~$ export PYTHON_KEYRING_BACKEND=keyrings.alt.file.EncryptedKeyring
ubuntu@phased-updater-ops:~$ charmcraft login
charmcraft internal error: ModuleNotFoundError("No module named 'keyrings'")
Probably because the python3-keyrings.alt package is not installed inside the snap. Therefore I seem to be forced to export the plain text version of the authentication to a text file with --export.
Steps to reproduce
Just run charmcraft login on a headless system.
As a second step, export PYTHON_KEYRING_BACKEND=keyrings.alt.file.EncryptedKeyring and run charmcraft login again to get the ModuleNotFoundError.
Environment
Ubuntu 24.04 VM.
Log output
2026-05-07 19:51:24.841 charmcraft internal error: ModuleNotFoundError("No module named 'keyrings'")
2026-05-07 19:51:24.844 Traceback (most recent call last):
2026-05-07 19:51:24.844 File "/snap/charmcraft/7517/lib/python3.12/site-packages/craft_application/application.py", line 663, in run
2026-05-07 19:51:24.844 return_code = self._run_inner()
2026-05-07 19:51:24.844 ^^^^^^^^^^^^^^^^^
2026-05-07 19:51:24.844 File "/snap/charmcraft/7517/lib/python3.12/site-packages/charmcraft/application/main.py", line 143, in _run_inner
2026-05-07 19:51:24.844 return super()._run_inner()
2026-05-07 19:51:24.844 ^^^^^^^^^^^^^^^^^^^^
2026-05-07 19:51:24.844 File "/snap/charmcraft/7517/lib/python3.12/site-packages/craft_application/application.py", line 640, in _run_inner
2026-05-07 19:51:24.844 return_code = dispatcher.run() or os.EX_OK
2026-05-07 19:51:24.844 ^^^^^^^^^^^^^^^^
2026-05-07 19:51:24.844 File "/snap/charmcraft/7517/lib/python3.12/site-packages/craft_cli/dispatcher.py", line 564, in run
2026-05-07 19:51:24.844 return self._loaded_command.run(self._parsed_command_args)
2026-05-07 19:51:24.844 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2026-05-07 19:51:24.844 File "/snap/charmcraft/7517/lib/python3.12/site-packages/charmcraft/application/commands/store.py", line 218, in run
2026-05-07 19:51:24.844 self._services.store.login(packages=packages, **kwargs)
2026-05-07 19:51:24.844 ^^^^^^^^^^^^^^^^^^^^
2026-05-07 19:51:24.844 File "/snap/charmcraft/7517/lib/python3.12/site-packages/craft_application/services/service_factory.py", line 333, in __getattr__
2026-05-07 19:51:24.844 result = self.get_class(name) if name.endswith("Class") else self.get(name)
2026-05-07 19:51:24.844 ^^^^^^^^^^^^^^
2026-05-07 19:51:24.844 File "/snap/charmcraft/7517/lib/python3.12/site-packages/craft_application/services/service_factory.py", line 318, in get
2026-05-07 19:51:24.844 instance.setup()
2026-05-07 19:51:24.844 File "/snap/charmcraft/7517/lib/python3.12/site-packages/charmcraft/services/store.py", line 199, in setup
2026-05-07 19:51:24.844 super().setup()
2026-05-07 19:51:24.844 File "/snap/charmcraft/7517/lib/python3.12/site-packages/charmcraft/services/store.py", line 90, in setup
2026-05-07 19:51:24.844 self.client = self.ClientClass(
2026-05-07 19:51:24.844 ^^^^^^^^^^^^^^^^^
2026-05-07 19:51:24.844 File "/snap/charmcraft/7517/lib/python3.12/site-packages/charmcraft/store/client.py", line 163, in __init__
2026-05-07 19:51:24.844 super().__init__(
2026-05-07 19:51:24.844 File "/snap/charmcraft/7517/lib/python3.12/site-packages/craft_store/store_client.py", line 93, in __init__
2026-05-07 19:51:24.844 super().__init__(
2026-05-07 19:51:24.844 File "/snap/charmcraft/7517/lib/python3.12/site-packages/craft_store/base_client.py", line 79, in __init__
2026-05-07 19:51:24.844 self._auth = Auth(
2026-05-07 19:51:24.844 ^^^^^
2026-05-07 19:51:24.844 File "/snap/charmcraft/7517/lib/python3.12/site-packages/craft_store/auth.py", line 192, in __init__
2026-05-07 19:51:24.844 self._keyring = keyring.get_keyring()
2026-05-07 19:51:24.844 ^^^^^^^^^^^^^^^^^^^^^
2026-05-07 19:51:24.844 File "/snap/charmcraft/7517/lib/python3.12/site-packages/keyring/core.py", line 33, in get_keyring
2026-05-07 19:51:24.844 init_backend()
2026-05-07 19:51:24.844 File "/snap/charmcraft/7517/lib/python3.12/site-packages/keyring/core.py", line 91, in init_backend
2026-05-07 19:51:24.844 set_keyring(_detect_backend(limit))
2026-05-07 19:51:24.844 ^^^^^^^^^^^^^^^^^^^^^^
2026-05-07 19:51:24.844 File "/snap/charmcraft/7517/lib/python3.12/site-packages/keyring/core.py", line 105, in _detect_backend
2026-05-07 19:51:24.844 load_env()
2026-05-07 19:51:24.844 File "/snap/charmcraft/7517/lib/python3.12/site-packages/keyring/core.py", line 151, in load_env
2026-05-07 19:51:24.844 return load_keyring(os.environ['PYTHON_KEYRING_BACKEND'])
2026-05-07 19:51:24.844 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2026-05-07 19:51:24.844 File "/snap/charmcraft/7517/lib/python3.12/site-packages/keyring/core.py", line 142, in load_keyring
2026-05-07 19:51:24.844 class_ = _load_keyring_class(keyring_name)
2026-05-07 19:51:24.844 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2026-05-07 19:51:24.844 File "/snap/charmcraft/7517/lib/python3.12/site-packages/keyring/core.py", line 132, in _load_keyring_class
2026-05-07 19:51:24.844 __import__(module_name)
2026-05-07 19:51:24.844 ModuleNotFoundError: No module named 'keyrings'
Check existing issues
Bug description
On a headless system,
charmcraft loginwarns that it failed to obtain a keyring and that every store interaction will go through the web authentication process again:If I try to switch to the
python3-keyrings.altpackage and theEncryptedFilekeyring type, it also fails:Probably because the
python3-keyrings.altpackage is not installed inside the snap. Therefore I seem to be forced to export the plain text version of the authentication to a text file with--export.Steps to reproduce
Just run
charmcraft loginon a headless system.As a second step, export
PYTHON_KEYRING_BACKEND=keyrings.alt.file.EncryptedKeyringand runcharmcraft loginagain to get theModuleNotFoundError.Environment
Ubuntu 24.04 VM.
Log output