Debugging snapcraft

I always forget how to get snapcraft to give me debugging information, so I’m writing it down here for future me and anyone else who might benefit.

To get debug logs out of snapcraft, one would think to use --debug but no, that’s a trap.

https://media.giphy.com/media/lk0TFUdop2JTW/giphy.gif

The correct invocation is to set SNAPCRAFT_ENABLE_DEVELOPER_DEBUG to something truthy, e.g. ‘yes’

$ SNAPCRAFT_ENABLE_DEVELOPER_DEBUG=yes snapcraft export-login foo.acl
Starting snapcraft 3.0.1 from /snap/snapcraft/2374/lib/python3.5/site-packages/snapcraft/cli.
Parts dir /home/acollard/parts
Stage dir /home/acollard/stage
Prime dir /home/acollard/prime
Parts dir /home/acollard/parts
Stage dir /home/acollard/stage
Prime dir /home/acollard/prime
Parts dir /home/acollard/parts
Stage dir /home/acollard/stage
Prime dir /home/acollard/prime
Parts dir /home/acollard/parts
Stage dir /home/acollard/stage
Prime dir /home/acollard/prime
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: 
Password: 
Store error response: {'_next': None, 'encoding': 'utf-8', '_content': b'{"error_list": [{"message": "Invalid request data", "code": "invalid-data", "extra": {"email": ["Enter a valid email address."]}}], "message": "Invalid request data", "code": "INVALID_DATA", "extra": {"email": ["Enter a valid email address."]}}', 'history': [], 'headers': {'Content-Type': 'application/json; charset=utf-8', 'Connection': 'close', 'x-xss-protection': '1; mode=block', 'X-Bzr-Revision-Number': '1668', 'X-Request-Id': 'XDMf4X8AAQEAABmHGIYAAAAm1', 'Date': 'Mon, 07 Jan 2019 09:46:09 GMT', 'Content-Length': '244', 'X-Frame-Options': 'SAMEORIGIN', 'Content-Language': 'en', 'strict-transport-security': 'max-age=15768000; includeSubDomains; preload', 'Server': 'gunicorn/19.3.0', 'x-content-type-options': 'nosniff', 'Vary': 'Accept,Authorization,Accept-Language,Cookie'}, '_content_consumed': True, 'request': <PreparedRequest [POST]>, 'connection': <requests.adapters.HTTPAdapter object at 0x7f4332c05710>, 'raw': <urllib3.response.HTTPResponse object at 0x7f43302502b0>, 'reason': 'Bad Request', 'status_code': 400, 'url': 'https://login.ubuntu.com/api/v2/tokens/discharge', 'cookies': <RequestsCookieJar[]>, 'elapsed': datetime.timedelta(0, 0, 84956)}
Traceback (most recent call last):
  File "/snap/snapcraft/2374/bin/snapcraft", line 11, in <module>
    load_entry_point('snapcraft==3.0.1', 'console_scripts', 'snapcraft')()
  File "/snap/snapcraft/2374/lib/python3.5/site-packages/snapcraft/cli/__main__.py", line 81, in run
    run_snapcraft(prog_name="snapcraft")
  File "/snap/snapcraft/2374/lib/python3.5/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/snap/snapcraft/2374/lib/python3.5/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/snap/snapcraft/2374/lib/python3.5/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/snap/snapcraft/2374/lib/python3.5/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/snap/snapcraft/2374/lib/python3.5/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/snap/snapcraft/2374/lib/python3.5/site-packages/snapcraft/cli/store.py", line 373, in export_login
    save=False,
  File "/snap/snapcraft/2374/lib/python3.5/site-packages/snapcraft/_store.py", line 232, in login
    save=save,
  File "/snap/snapcraft/2374/lib/python3.5/site-packages/snapcraft/_store.py", line 171, in _try_login
    save=save,
  File "/snap/snapcraft/2374/lib/python3.5/site-packages/snapcraft/storeapi/_store_client.py", line 67, in login
    email, password, one_time_password, caveat_id
  File "/snap/snapcraft/2374/lib/python3.5/site-packages/snapcraft/storeapi/_sso_client.py", line 49, in get_unbound_discharge
    "Failed to get unbound discharge", response
snapcraft.storeapi.errors.StoreAuthenticationError: Authentication error: Failed to get unbound discharge: Invalid request data
3 Likes