"snapcraft login" command not working

Hi, I’m having issue logging to snapcraft via command line. It works fine on 1 of my computers but not on the other. Both are using Ubuntu 20.04 and snapcraft 8.2.1.

The command just hang on Running snapcraft login on host. When running the command with the verbosity set to trace I get:

$ snapcraft login --verbosity trace
2024-05-01 12:55:08.234 Starting snapcraft, version 8.2.1                                              
2024-05-01 12:55:08.234 Logging execution to '/home/ruggy/.local/state/snapcraft/log/snapcraft-20240501-125508.233899.log'                                                                                     
2024-05-01 12:55:08.234 Raw pre-parsed sysargs: args={'help': False, 'verbose': False, 'quiet': False, 'verbosity': 'trace', 'version': False} filtered=['login']                                              
2024-05-01 12:55:08.234 General parsed sysargs: command='login' args=[]                                
2024-05-01 12:55:08.234 Configuring application...                                                     
2024-05-01 12:55:08.234 Preparing application...                                                       
2024-05-01 12:55:08.235 Command parsed sysargs: Namespace(login_with=None, experimental_login=False)   
2024-05-01 12:55:08.235 Build plan: platform=None, build_for=None                                      
2024-05-01 12:55:08.235 Running snapcraft login on host / (539.1s)

The machine on which the command isn’t working has internet and is a quite fresh Ubuntu install so I suspect I might be missing a package but I don’t which one.

Any suggestion?

Thanks.

Do you get any traceback or error messages if you call CRAFT_DEBUG=1 snapcraft login --verbosity=trace and Control+C once it starts hanging?

And is there any more info in the log file? (where it says Logging execution to '/home...)

If I had to guess, it’s waiting for the gnome-keyring to unlock, which is either not installed or the GUI prompt is not showing up for some reason. Do you happen to be ssh’ing into this computer or on a tty?

1 Like

Hi, I was indeed ssh’ing into the machine. I manage to fix the issue by plugging in a monitor and logging into the machine locally. Then the snapcraft login command worked both locally and via ssh.

Thanks for the help.

Here is the whole log after I Ctrl+C while it was hanging, just in case:

2024-05-01 15:24:39.878 Starting snapcraft, version 8.2.1
2024-05-01 15:24:39.878 Log verbosity level set to BRIEF
2024-05-01 15:24:39.888 Falling back from craft-application to snapcraft.
2024-05-01 15:24:39.888 Raw pre-parsed sysargs: args={'help': False, 'verbose': False, 'quiet': False, 'verbosity': 'trace', 'version': False, 'trace': False} filtered=['login']
2024-05-01 15:24:39.888 General parsed sysargs: command='login' args=[]
2024-05-01 15:24:39.888 Not completing command configuration
2024-05-01 15:24:39.888 Command parsed sysargs: Namespace(login_with=None, experimental_login=False)
2024-05-01 15:25:16.510 Interrupted.
2024-05-01 15:25:16.514 Traceback (most recent call last):
2024-05-01 15:25:16.514   File "/snap/snapcraft/11471/lib/python3.10/site-packages/snapcraft/application.py", line 361, in main
2024-05-01 15:25:16.514     return app.run()
2024-05-01 15:25:16.514   File "/snap/snapcraft/11471/lib/python3.10/site-packages/craft_application/application.py", line 481, in run
2024-05-01 15:25:16.514     dispatcher = self._get_dispatcher()
2024-05-01 15:25:16.514   File "/snap/snapcraft/11471/lib/python3.10/site-packages/snapcraft/application.py", line 220, in _get_dispatcher
2024-05-01 15:25:16.514     raise errors.ClassicFallback()
2024-05-01 15:25:16.514 snapcraft.errors.ClassicFallback
2024-05-01 15:25:16.514 
2024-05-01 15:25:16.514 During handling of the above exception, another exception occurred:
2024-05-01 15:25:16.514 Traceback (most recent call last):
2024-05-01 15:25:16.515   File "/snap/snapcraft/11471/lib/python3.10/site-packages/snapcraft/cli.py", line 222, in run
2024-05-01 15:25:16.515     _run_dispatcher(dispatcher, global_args)
2024-05-01 15:25:16.515   File "/snap/snapcraft/11471/lib/python3.10/site-packages/snapcraft/cli.py", line 194, in _run_dispatcher
2024-05-01 15:25:16.515     dispatcher.run()
2024-05-01 15:25:16.515   File "/snap/snapcraft/11471/lib/python3.10/site-packages/craft_cli/dispatcher.py", line 487, in run
2024-05-01 15:25:16.515     return self._loaded_command.run(self._parsed_command_args)
2024-05-01 15:25:16.515   File "/snap/snapcraft/11471/lib/python3.10/site-packages/snapcraft/commands/account.py", line 114, in run
2024-05-01 15:25:16.515     store.StoreClientCLI().login()
2024-05-01 15:25:16.515   File "/snap/snapcraft/11471/lib/python3.10/site-packages/snapcraft/store/client.py", line 179, in __init__
2024-05-01 15:25:16.515     self.store_client = get_client(ephemeral=ephemeral)
2024-05-01 15:25:16.515   File "/snap/snapcraft/11471/lib/python3.10/site-packages/snapcraft/store/client.py", line 161, in get_client
2024-05-01 15:25:16.515     client = craft_store.UbuntuOneStoreClient(
2024-05-01 15:25:16.516   File "/snap/snapcraft/11471/lib/python3.10/site-packages/craft_store/ubuntu_one_store_client.py", line 47, in __init__
2024-05-01 15:25:16.516     super().__init__(
2024-05-01 15:25:16.516   File "/snap/snapcraft/11471/lib/python3.10/site-packages/craft_store/base_client.py", line 77, in __init__
2024-05-01 15:25:16.516     self._auth = Auth(
2024-05-01 15:25:16.516   File "/snap/snapcraft/11471/lib/python3.10/site-packages/craft_store/auth.py", line 192, in __init__
2024-05-01 15:25:16.516     self._keyring.get_preferred_collection()
2024-05-01 15:25:16.516   File "/snap/snapcraft/11471/lib/python3.10/site-packages/keyring/backends/SecretService.py", line 65, in get_preferred_collection
2024-05-01 15:25:16.516     collection.unlock()
2024-05-01 15:25:16.516   File "/snap/snapcraft/11471/lib/python3.10/site-packages/secretstorage/collection.py", line 68, in unlock
2024-05-01 15:25:16.516     return unlock_objects(self.connection, [self.collection_path])
2024-05-01 15:25:16.516   File "/snap/snapcraft/11471/lib/python3.10/site-packages/secretstorage/util.py", line 159, in unlock_objects
2024-05-01 15:25:16.516     dismissed, (signature, unlocked) = exec_prompt(connection, prompt)
2024-05-01 15:25:16.516   File "/snap/snapcraft/11471/lib/python3.10/site-packages/secretstorage/util.py", line 145, in exec_prompt
2024-05-01 15:25:16.516     dismissed, result = connection.recv_until_filtered(signals).body
2024-05-01 15:25:16.517   File "/snap/snapcraft/11471/lib/python3.10/site-packages/jeepney/io/blocking.py", line 242, in recv_until_filtered
2024-05-01 15:25:16.517     self.recv_messages(timeout=deadline_to_timeout(deadline))
2024-05-01 15:25:16.517   File "/snap/snapcraft/11471/lib/python3.10/site-packages/jeepney/io/blocking.py", line 172, in recv_messages
2024-05-01 15:25:16.517     msg = self.receive(timeout=timeout)
2024-05-01 15:25:16.517   File "/snap/snapcraft/11471/lib/python3.10/site-packages/jeepney/io/blocking.py", line 165, in receive
2024-05-01 15:25:16.517     return self._receive(timeout_to_deadline(timeout))
2024-05-01 15:25:16.517   File "/snap/snapcraft/11471/lib/python3.10/site-packages/jeepney/io/blocking.py", line 102, in _receive
2024-05-01 15:25:16.517     b, fds = self._read_some_data(timeout=deadline_to_timeout(deadline))
2024-05-01 15:25:16.517   File "/snap/snapcraft/11471/lib/python3.10/site-packages/jeepney/io/blocking.py", line 106, in _read_some_data
2024-05-01 15:25:16.517     for key, ev in self.selector.select(timeout):
2024-05-01 15:25:16.517   File "/snap/snapcraft/11471/usr/lib/python3.10/selectors.py", line 469, in select
2024-05-01 15:25:16.518     fd_event_list = self._selector.poll(timeout, max_ev)
2024-05-01 15:25:16.518 KeyboardInterrupt
2024-05-01 15:25:16.518 Full execution log: '/home/ruggy/.local/state/snapcraft/log/snapcraft-20240501-152439.877625.log'

Thanks, glad you got it figured out.

So the problem is that snapcraft asked for the keyring to be unlocked, gnome-keyring tries to open a GUI unlock prompt, but you are ssh’ed into an Ubuntu desktop so the prompt isn’t visible and there are no errors - it just hangs.

We need to figure out how to solve this problem. I’m not sure if it’s something Snapcraft can detect and handle or if we need to work with the upstream keyring library.

gnome-keyring used to fallback to a cli based password prompt, it no longer does.

We should better catch the error, point to documentation (as I think we do already) and instruct on how to fallback to non-keyring logins.

In all fairness, it looks like we should be working with the desktop team on a good solution here.