charmcraft 3.1.1 fails to fetch-lib

I’m trying to fetch-lib to develop a machine charm, but charmcraft blows up:


$ charmcraft fetch-lib 
charmcraft internal error: ParserError('while parsing a block mapping', <yaml.error.Mark object at 0x766c9690dc00>, "expected <block end>, but found '<block mapping start>'", <yaml.error.Mark object at 0x766c9690ded0>)                                                       
Full execution log: '/home/erik/.local/state/charmcraft/log/charmcraft-20240803-002322.166377.log'                                      

The logs:

erik@frozen:~/reth-operator$ cat /home/erik/.local/state/charmcraft/log/charmcraft-20240803-002322.166377.log
2024-08-03 00:23:22.168 Starting charmcraft, version 3.1.1
2024-08-03 00:23:22.168 Log verbosity level set to BRIEF
2024-08-03 00:23:22.168 Configuring application...
2024-08-03 00:23:22.168 Preparing application...
2024-08-03 00:23:22.169 Build plan: platform=None, build_for=None
2024-08-03 00:23:22.169 Loading project file '/home/erik/reth-operator/charmcraft.yaml'
2024-08-03 00:23:22.172 charmcraft internal error: ParserError('while parsing a block mapping', <yaml.error.Mark object at 0x766c9690dc00>, "expected <block end>, but found '<block mapping start>'", <yaml.error.Mark object at 0x766c9690ded0>)
2024-08-03 00:23:22.173 Traceback (most recent call last):
2024-08-03 00:23:22.173   File "/snap/charmcraft/4264/lib/python3.10/site-packages/craft_application/application.py", line 529, in run
2024-08-03 00:23:22.173     self.services.project = self.get_project(
2024-08-03 00:23:22.173   File "/snap/charmcraft/4264/lib/python3.10/site-packages/craft_application/application.py", line 282, in get_project
2024-08-03 00:23:22.173     yaml_data = util.safe_yaml_load(file)
2024-08-03 00:23:22.173   File "/snap/charmcraft/4264/lib/python3.10/site-packages/craft_application/util/yaml.py", line 104, in safe_yaml_load
2024-08-03 00:23:22.173     return yaml.load(stream, Loader=_SafeYamlLoader)  # noqa: S506
2024-08-03 00:23:22.173   File "/snap/charmcraft/4264/lib/python3.10/site-packages/yaml/__init__.py", line 81, in load
2024-08-03 00:23:22.173     return loader.get_single_data()
2024-08-03 00:23:22.173   File "/snap/charmcraft/4264/lib/python3.10/site-packages/yaml/constructor.py", line 49, in get_single_data
2024-08-03 00:23:22.173     node = self.get_single_node()
2024-08-03 00:23:22.173   File "/snap/charmcraft/4264/lib/python3.10/site-packages/yaml/composer.py", line 36, in get_single_node
2024-08-03 00:23:22.173     document = self.compose_document()
2024-08-03 00:23:22.173   File "/snap/charmcraft/4264/lib/python3.10/site-packages/yaml/composer.py", line 55, in compose_document
2024-08-03 00:23:22.173     node = self.compose_node(None, None)
2024-08-03 00:23:22.173   File "/snap/charmcraft/4264/lib/python3.10/site-packages/yaml/composer.py", line 84, in compose_node
2024-08-03 00:23:22.173     node = self.compose_mapping_node(anchor)
2024-08-03 00:23:22.173   File "/snap/charmcraft/4264/lib/python3.10/site-packages/yaml/composer.py", line 133, in compose_mapping_node
2024-08-03 00:23:22.173     item_value = self.compose_node(node, item_key)
2024-08-03 00:23:22.173   File "/snap/charmcraft/4264/lib/python3.10/site-packages/yaml/composer.py", line 84, in compose_node
2024-08-03 00:23:22.173     node = self.compose_mapping_node(anchor)
2024-08-03 00:23:22.173   File "/snap/charmcraft/4264/lib/python3.10/site-packages/yaml/composer.py", line 133, in compose_mapping_node
2024-08-03 00:23:22.173     item_value = self.compose_node(node, item_key)
2024-08-03 00:23:22.173   File "/snap/charmcraft/4264/lib/python3.10/site-packages/yaml/composer.py", line 84, in compose_node
2024-08-03 00:23:22.173     node = self.compose_mapping_node(anchor)
2024-08-03 00:23:22.173   File "/snap/charmcraft/4264/lib/python3.10/site-packages/yaml/composer.py", line 133, in compose_mapping_node
2024-08-03 00:23:22.173     item_value = self.compose_node(node, item_key)
2024-08-03 00:23:22.173   File "/snap/charmcraft/4264/lib/python3.10/site-packages/yaml/composer.py", line 84, in compose_node
2024-08-03 00:23:22.173     node = self.compose_mapping_node(anchor)
2024-08-03 00:23:22.173   File "/snap/charmcraft/4264/lib/python3.10/site-packages/yaml/composer.py", line 127, in compose_mapping_node
2024-08-03 00:23:22.173     while not self.check_event(MappingEndEvent):
2024-08-03 00:23:22.173   File "/snap/charmcraft/4264/lib/python3.10/site-packages/yaml/parser.py", line 98, in check_event
2024-08-03 00:23:22.173     self.current_event = self.state()
2024-08-03 00:23:22.173   File "/snap/charmcraft/4264/lib/python3.10/site-packages/yaml/parser.py", line 438, in parse_block_mapping_key
2024-08-03 00:23:22.173     raise ParserError("while parsing a block mapping", self.marks[-1],
2024-08-03 00:23:22.173 yaml.parser.ParserError: while parsing a block mapping
2024-08-03 00:23:22.173   in "/home/erik/reth-operator/charmcraft.yaml", line 29, column 6
2024-08-03 00:23:22.173 expected <block end>, but found '<block mapping start>'
2024-08-03 00:23:22.173   in "/home/erik/reth-operator/charmcraft.yaml", line 31, column 7
2024-08-03 00:23:22.173 Full execution log: '/home/erik/.local/state/charmcraft/log/charmcraft-20240803-002322.166377.log'

I’m running latest stable charmcraft snap.

erik@frozen:~/reth-operator$ sudo snap refresh charmcraft
[sudo] password for erik: 
snap "charmcraft" has no updates available

I’ll file a bug on this if I’m not doing something wrong?

So, I found the error was the charmcraft.yaml being malformed.

Once the yaml was fixed by chatGPT, everything worked.

I’m leaving this post here for reference.

Thanks for letting us know @erik-lonroth ! This turns out to be a bug that affects charmcraft, snapcraft and rockcraft, so I’ve reported it in our bug tracker.

1 Like