snapcraft icon indicating copy to clipboard operation
snapcraft copied to clipboard

Specifying nonstandard base results in strange error message

Open dilyn-corner opened this issue 1 year ago • 1 comments

Bug Description

When attempting to build a snap which declares a base not one of core{,18,20,22,24}, a "Bad snapcraft.yaml content" error occurs. This error does not reflect the reality of the snapcraft.yaml being used to build the snap.

To Reproduce

Tested with snapcraft 8.1.0.pst4+gitbe36b4dc (rev 11373). Use the provided snapcraft.yaml and execute snapcraft --verbosity=verbose.

Environment

Ubuntu 23.10, --use-lxd.

snapcraft.yaml

name: my-snap-name # you probably want to 'snapcraft register <name>'
base: foo # the base snap is the execution environment for this snap
version: '0.1' # just for humans, typically '1.2+git' or '1.3.2'
summary: Single-line elevator pitch for your amazing snap # 79 char long summary
description: |
  This is my-snap's description. You have a paragraph or two to tell the
  most important story about your snap. Keep it under 100 words though,
  we live in tweetspace and your description wants to look good in the snap
  store.

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

parts:
  my-part:
    # See 'snapcraft plugins'
    plugin: nil

Relevant log output

dilyn@Ares:~/test -> snapcraft 
Starting snapcraft, version 8.1.0.post4+gitbe36b4dc
Logging execution to '/home/dilyn/.local/state/snapcraft/log/snapcraft-20240416-130243.609661.log'
Running on amd64 for amd64
Bad snapcraft.yaml content:
- 'architectures' keyword is not supported for base 'foo'. Use 'platforms' keyword instead.
Full execution log: '/home/dilyn/.local/state/snapcraft/log/snapcraft-20240416-130243.609661.log'

Additional context

When using snapcraft 7.x, I instead get a keyError, as I would expect for an (invalid) base:

dilyn@Ares:~/test -> snapcraft_7
Starting Snapcraft 7.5.5
Logging execution to '/home/dilyn/.local/state/snapcraft/log/snapcraft-20240416-130407.161566.log'
Running on amd64 for amd64
Traceback (most recent call last):
  File "/snap/snapcraft/11039/bin/snapcraft", line 8, in <module>
    sys.exit(run())
  File "/snap/snapcraft_7/11039/lib/python3.8/site-packages/snapcraft/cli.py", line 256, in run
    _run_dispatcher(dispatcher, global_args)
  File "/snap/snapcraft_7/11039/lib/python3.8/site-packages/snapcraft/cli.py", line 229, in _run_dispatcher
    dispatcher.run()
  File "/snap/snapcraft_7/11039/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_7/11039/lib/python3.8/site-packages/snapcraft/commands/lifecycle.py", line 265, in run
    super().run(parsed_args)
  File "/snap/snapcraft_7/11039/lib/python3.8/site-packages/snapcraft/commands/lifecycle.py", line 138, in run
    parts_lifecycle.run(self.name, parsed_args)
  File "/snap/snapcraft_7/11039/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 216, in run
    _run_command(
  File "/snap/snapcraft_7/11039/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 262, in _run_command
    _run_in_provider(project, command_name, parsed_args)
  File "/snap/snapcraft_7/11039/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 545, in _run_in_provider
    build_base = providers.SNAPCRAFT_BASE_TO_PROVIDER_BASE[snapcraft_base]
KeyError: 'foo'

However, I also get a keyError just in case I specify a valid base, like core22-desktop.

dilyn-corner avatar Apr 16 '24 17:04 dilyn-corner

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-2818.

This message was autogenerated