snapcraft clean crashes on snapcraft.yaml with bad indent

Bug #1829564 reported by Dan Kegel
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Snapcraft
New
Undecided
Unassigned

Bug Description

snapcraft felt it was important I share this with you :-)

Running snapcraft on Ubuntu 19.04.

$ snapcraft --version
snapcraft, version 2.43.1+18.10

The log:

$ snapcraft clean
Sorry, an error occurred in Snapcraft:
Traceback (most recent call last):
  File "/usr/bin/snapcraft", line 11, in <module>
    load_entry_point('snapcraft==2.43.1+18.10', 'console_scripts', 'snapcraft')()
  ...
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 127, in compose_mapping_node
    while not self.check_event(MappingEndEvent):
  File "/usr/lib/python3/dist-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
  File "/usr/lib/python3/dist-packages/yaml/parser.py", line 439, in parse_block_mapping_key
    "expected <block end>, but found %r" % token.id, token.start_mark)
yaml.parser.ParserError: while parsing a block mapping
  in "snapcraft.yaml", line 19, column 3
expected <block end>, but found '<block mapping start>'
  in "snapcraft.yaml", line 36, column 4
We would appreciate it if you created a bug report at
https://launchpad.net/snapcraft/+filebug with the above text included.

The snapcraft.yaml provoking the crash (note the inconsistent indent level between the two parts):

name: fpm
version: 1.1
summary: Effing Package Management
description: |
  Build packages for multiple platforms (deb, rpm, etc) with great ease and sanity.
  http://fpm.readthedocs.io/en/latest/
grade: devel
confinement: devmode

apps:
  fpm:
    environment:
      RUBYLIB: $SNAP/usr/lib/ruby/2.3.0:$SNAP/usr/lib/x86_64-linux-gnu/ruby/2.3.0
      GEM_HOME: $SNAP/gems
      GEM_PATH: $SNAP
    command: ruby $SNAP/bin/fpm

parts:
  fpm:
    source: .
    plugin: nil
    build-packages:
       - build-essential
       - ruby-dev
       - rubygems-integration
       - libreadline-dev
       - libssl-dev
       - libtinfo-dev
    stage-packages:
       - ruby
       - rubygems-integration
    override-build: |
       snapcraftctl build
       gem install fpm -i $SNAPCRAFT_PART_INSTALL

   mangle-shebang:
    plugin: nil
    after: [fpm]
    override-build: |
       snapcraftctl build
       sed -i 's/#!\/usr\/bin\/ruby/#!\/usr\/bin\/env ruby/' $SNAPCRAFT_STAGE/usr/bin/{gem2.3,rdoc2.3,fpm,rake}

Removing the extra space at the start of the 'mangle-shebang:' line worked around the problem

Revision history for this message
Will Nilges (wilnil) wrote :
Download full text (4.6 KiB)

I believe I am experiencing the same bug:

Sorry, an error occurred in Snapcraft:
Traceback (most recent call last):
  File "/usr/bin/snapcraft", line 11, in <module>
    load_entry_point('snapcraft==2.43.1+18.4', 'console_scripts', 'snapcraft')()
  File "/usr/lib/python3/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1043, in invoke
    return Command.invoke(self, ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/lib/python3/dist-packages/snapcraft/cli/_runner.py", line 93, in run
    ctx.forward(lifecyclecli.commands["snap"])
  File "/usr/lib/python3/dist-packages/click/core.py", line 553, in forward
    return self.invoke(cmd, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/snapcraft/cli/lifecycle.py", line 136, in snap
    project = _execute(steps.PRIME, parts=[], **kwargs)
  File "/usr/lib/python3/dist-packages/snapcraft/cli/lifecycle.py", line 30, in _execute
    project = get_project(**kwargs)
  File "/usr/lib/python3/dist-packages/snapcraft/cli/_options.py", line 68, in get_project
    snapcraft_yaml_file_path=snapcraft_yaml_file_path,
  File "/usr/lib/python3/dist-packages/snapcraft/project/_project.py", line 48, in __init__
    self.info = ProjectInfo(snapcraft_yaml_file_path=snapcraft_yaml_file_path)
  File "/usr/lib/python3/dist-packages/snapcraft/project/_project_info.py", line 32, in __init__
    self.__raw_snapcraft = _load_yaml(yaml_file_path=snapcraft_yaml_file_path)
  File "/usr/lib/python3/dist-packages/snapcraft/project/_project_info.py", line 65, in _load_yaml
    yaml_contents = yaml.safe_load(fp) # type: ignore
  File "/usr/lib/python3/dist-packages/yaml/__init__.py", line 94, in safe_load
    return load(stream, SafeLoader)
  File "/usr/lib/python3/dist-packages/yaml/__init__.py", line 72, in load
    return loader.get_single_data()
  File "/usr/lib/python3/dist-packages/yaml/constructor.py", line 35, in get_single_data
    node = self.get_single_node()
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 36, in get_single_node
    document = self.compose_document()
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 55, in compose_document
    node = self.compose_node(None, None)
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_ma...

Read more...

Revision history for this message
Will Nilges (wilnil) wrote :

Fixed by properly indenting my parts: and adding a colon to the source entry under crypto-test

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.