In clean ubuntu:20.04 and ubuntu:22.04 lxd containers, using snapcraft 7.2.10 (revision 8674) the “Using a keyring on a headless Linux system” instructions do not work. In the fresh container, after installing snapcraft I initially get
ubuntu@snapcraft-login-test-3:~$ snapcraft login
craft-store error: No keyring found to store or retrieve credentials from.
Recommended resolution: Ensure the keyring is working or SNAPCRAFT_STORE_CREDENTIALS is correctly exported into the environment
For more information, check out: https://snapcraft.io/docs/snapcraft-authentication
Full execution log: '/home/ubuntu/.cache/snapcraft/log/snapcraft-20230125-203430.755481.log'
as you would expect. I then install gnome-keyring
. Then running
ubuntu@snapcraft-login-test-3:~$ dbus-run-session -- sh
$ gnome-keyring-daemon --unlock
gives no output at all, instead of prompting for a passphrase. I can then do one of two things, each which gives the same result: 1) I can leave the above command hanging and open a new shell in the same LXD container or 2) I can just press ctrl+D, which drops me back into my dbus-run-session -- sh
shell.
In either scenario, when I then try to run snapcraft login
, I get the normal prompt for my email, enter it, get a prompt for my password, enter it and press enter, and then snapcraft throws an exception and I get a whole bunch of stacktraces, as seen below:
ubuntu@snapcraft-login-test-3:~$ snapcraft login
Enter your Ubuntu One e-mail address and password.
If you do not have an Ubuntu One account, you can create one at https://snapcraft.io/account
Email: <redacting my email>
Password:
Traceback (most recent call last):
File "/snap/snapcraft/8674/lib/python3.8/site-packages/secretstorage/util.py", line 48, in send_and_get_reply
raise DBusErrorResponse(resp_msg)
jeepney.wrappers.DBusErrorResponse: [org.freedesktop.DBus.Error.UnknownMethod] ('No such interface “org.freedesktop.DBus.Properties” on object at path /org/freedesktop/secrets/collection/login',)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/snap/snapcraft/8674/lib/python3.8/site-packages/secretstorage/collection.py", line 177, in get_default_collection
return Collection(connection)
File "/snap/snapcraft/8674/lib/python3.8/site-packages/secretstorage/collection.py", line 45, in __init__
self._collection.get_property('Label')
File "/snap/snapcraft/8674/lib/python3.8/site-packages/secretstorage/util.py", line 67, in get_property
(signature, value), = self.send_and_get_reply(msg)
File "/snap/snapcraft/8674/lib/python3.8/site-packages/secretstorage/util.py", line 52, in send_and_get_reply
raise ItemNotFoundException('Item does not exist!') from resp
secretstorage.exceptions.ItemNotFoundException: Item does not exist!
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/snap/snapcraft/8674/lib/python3.8/site-packages/keyring/backends/SecretService.py", line 61, in get_preferred_collection
collection = secretstorage.get_default_collection(bus)
File "/snap/snapcraft/8674/lib/python3.8/site-packages/secretstorage/collection.py", line 179, in get_default_collection
return create_collection(connection, 'Default', 'default', session)
File "/snap/snapcraft/8674/lib/python3.8/site-packages/secretstorage/collection.py", line 159, in create_collection
raise PromptDismissedException('Prompt dismissed.')
secretstorage.exceptions.PromptDismissedException: Prompt dismissed.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/snap/snapcraft/8674/bin/snapcraft", line 8, in <module>
sys.exit(run())
File "/snap/snapcraft/8674/lib/python3.8/site-packages/snapcraft/cli.py", line 228, in run
_run_dispatcher(dispatcher)
File "/snap/snapcraft/8674/lib/python3.8/site-packages/snapcraft/cli.py", line 204, in _run_dispatcher
dispatcher.run()
File "/snap/snapcraft/8674/lib/python3.8/site-packages/craft_cli/dispatcher.py", line 448, in run
return self._loaded_command.run(self._parsed_command_args)
File "/snap/snapcraft/8674/lib/python3.8/site-packages/snapcraft/commands/account.py", line 113, in run
store.StoreClientCLI().login()
File "/snap/snapcraft/8674/lib/python3.8/site-packages/snapcraft/store/client.py", line 216, in login
credentials = self.store_client.login(
File "/snap/snapcraft/8674/lib/python3.8/site-packages/craft_store/base_client.py", line 130, in login
self._auth.ensure_no_credentials()
File "/snap/snapcraft/8674/lib/python3.8/site-packages/craft_store/auth.py", line 131, in ensure_no_credentials
if self._keyring.get_password(self.application_name, self.host) is not None:
File "/snap/snapcraft/8674/lib/python3.8/site-packages/keyring/backends/SecretService.py", line 78, in get_password
collection = self.get_preferred_collection()
File "/snap/snapcraft/8674/lib/python3.8/site-packages/keyring/backends/SecretService.py", line 63, in get_preferred_collection
raise InitError("Failed to create the collection: %s." % e)
keyring.errors.InitError: Failed to create the collection: Prompt dismissed..
Alternatively, if (similarly to the first route above) I leave gnome-keyring-daemon --unlock
hanging in the first shell and open a new shell in the same lxd container but instead of directly running snapcraft login
I run dbus-run-session -- sh
and then snapcraft login
, I get the following, with the stacktrace only coming after 2 minutes of nothing
ubuntu@snapcraft-login-test-3:~$ dbus-run-session -- sh
$ snapcraft login
dbus-daemon[3014]: [session uid=1000 pid=3014] Activating service name='org.freedesktop.systemd1' requested by ':1.0' (uid=1000 pid=3016 comm="snapcraft login " label="unconfined")
dbus-daemon[3014]: [session uid=1000 pid=3014] Activated service 'org.freedesktop.systemd1' failed: Process org.freedesktop.systemd1 exited with status 1
Enter your Ubuntu One e-mail address and password.
If you do not have an Ubuntu One account, you can create one at https://snapcraft.io/account
Email: <redacting my email>
Password:
dbus-daemon[3014]: [session uid=1000 pid=3014] Activating service name='org.freedesktop.secrets' requested by ':1.5' (uid=1000 pid=3016 comm="/snap/snapcraft/8674/bin/python /snap/snapcraft/86" label="snap.snapcraft.snapcraft (complain)")
SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
dbus-daemon[3014]: [session uid=1000 pid=3014] Failed to activate service 'org.freedesktop.secrets': timed out (service_start_timeout=120000ms)
Traceback (most recent call last):
File "/snap/snapcraft/8674/bin/snapcraft", line 8, in <module>
sys.exit(run())
File "/snap/snapcraft/8674/lib/python3.8/site-packages/snapcraft/cli.py", line 228, in run
_run_dispatcher(dispatcher)
File "/snap/snapcraft/8674/lib/python3.8/site-packages/snapcraft/cli.py", line 204, in _run_dispatcher
dispatcher.run()
File "/snap/snapcraft/8674/lib/python3.8/site-packages/craft_cli/dispatcher.py", line 448, in run
return self._loaded_command.run(self._parsed_command_args)
File "/snap/snapcraft/8674/lib/python3.8/site-packages/snapcraft/commands/account.py", line 113, in run
store.StoreClientCLI().login()
File "/snap/snapcraft/8674/lib/python3.8/site-packages/snapcraft/store/client.py", line 216, in login
credentials = self.store_client.login(
File "/snap/snapcraft/8674/lib/python3.8/site-packages/craft_store/base_client.py", line 130, in login
self._auth.ensure_no_credentials()
File "/snap/snapcraft/8674/lib/python3.8/site-packages/craft_store/auth.py", line 131, in ensure_no_credentials
if self._keyring.get_password(self.application_name, self.host) is not None:
File "/snap/snapcraft/8674/lib/python3.8/site-packages/keyring/backends/SecretService.py", line 78, in get_password
collection = self.get_preferred_collection()
File "/snap/snapcraft/8674/lib/python3.8/site-packages/keyring/backends/SecretService.py", line 61, in get_preferred_collection
collection = secretstorage.get_default_collection(bus)
File "/snap/snapcraft/8674/lib/python3.8/site-packages/secretstorage/collection.py", line 177, in get_default_collection
return Collection(connection)
File "/snap/snapcraft/8674/lib/python3.8/site-packages/secretstorage/collection.py", line 45, in __init__
self._collection.get_property('Label')
File "/snap/snapcraft/8674/lib/python3.8/site-packages/secretstorage/util.py", line 67, in get_property
(signature, value), = self.send_and_get_reply(msg)
File "/snap/snapcraft/8674/lib/python3.8/site-packages/secretstorage/util.py", line 48, in send_and_get_reply
raise DBusErrorResponse(resp_msg)
jeepney.wrappers.DBusErrorResponse: [org.freedesktop.DBus.Error.TimedOut] ("Failed to activate service 'org.freedesktop.secrets': timed out (service_start_timeout=120000ms)",)
$
Also, as a nitpick it looks like there’s an extra closed parenthesis in the hyperlinks at the top of the post