Snapcraft Build Errors: Lifecycle with traceback

Hello,

It is strange that the error I am about to post did not appear a couple of days ago…I would like to understand what it means…maybe reverting my snapcraft versions helps with something ?
Snapcraft version: 2.42.1.
Error log:

Sorry, Snapcraft ran into an error when trying to running through its
lifecycle that generated the following traceback:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/elftools/construct/core.py", line 351, in _parse
    return self.packer.unpack(_read_stream(stream, self.length))[0]
  File "/usr/lib/python3/dist-packages/elftools/construct/core.py", line 293, in _read_stream
    raise FieldError("expected %d, found %d" % (length, len(data)))
elftools.construct.core.FieldError: expected 4, found 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/elftools/common/utils.py", line 32, in struct_parse
    return struct.parse_stream(stream)
  File "/usr/lib/python3/dist-packages/elftools/construct/core.py", line 190, in parse_stream
    return self._parse(stream, Container())
  File "/usr/lib/python3/dist-packages/elftools/construct/core.py", line 647, in _parse
    subobj = sc._parse(stream, context)
  File "/usr/lib/python3/dist-packages/elftools/construct/core.py", line 353, in _parse
    raise FieldError(ex)
elftools.construct.core.FieldError: expected 4, found 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/snapcraft", line 9, in <module>
    load_entry_point('snapcraft==2.42.1', 'console_scripts', 'snapcraft')()
  File "/usr/lib/python3/dist-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1037, in invoke
    return Command.invoke(self, ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 534, 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 79, in run
    ctx.forward(lifecyclecli.commands['snap'])
  File "/usr/lib/python3/dist-packages/click/core.py", line 552, in forward
    return self.invoke(cmd, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/snapcraft/cli/lifecycle.py", line 135, in snap
    project_options, directory=directory, output=output)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle/_packer.py", line 46, in snap
    execute('prime', project_options)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle/_runner.py", line 79, in execute
    _Executor(config, project_options).run(step, part_names)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle/_runner.py", line 191, in run
    self._run_step(step, part, part_names)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle/_runner.py", line 236, in _run_step
    getattr(part, step)()
  File "/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler/__init__.py", line 601, in prime
    self._runner.prime()
  File "/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler/_runner.py", line 117, in prime
    self._primedir)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler/_runner.py", line 160, in _run_scriptlet
    scriptlet_name, function_call.strip())))
  File "/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler/_runner.py", line 208, in _handle_builtin_function
    function(**function_args)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler/__init__.py", line 613, in _do_prime
    dependency_paths = self._handle_elf(snap_files)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler/__init__.py", line 620, in _handle_elf
    elf_files = elf.get_elf_files(self.primedir, snap_files)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/elf.py", line 605, in get_elf_files
    elf_file = ElfFile(path=path)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/elf.py", line 199, in __init__
    elf_data = self._extract(path)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/elf.py", line 214, in _extract
    elf = elftools.elf.elffile.ELFFile(fp)
  File "/usr/lib/python3/dist-packages/elftools/elf/elffile.py", line 59, in __init__
    self._file_stringtable_section = self._get_file_stringtable()
  File "/usr/lib/python3/dist-packages/elftools/elf/elffile.py", line 348, in _get_file_stringtable
    header=self._get_section_header(stringtable_section_num),
  File "/usr/lib/python3/dist-packages/elftools/elf/elffile.py", line 248, in _get_section_header
    stream_pos=self._section_offset(n))
  File "/usr/lib/python3/dist-packages/elftools/common/utils.py", line 34, in struct_parse
    raise ELFParseError(str(e))
elftools.common.exceptions.ELFParseError: expected 4, found 0

How are you running snapcraft, is this a running from deb or source? Do you have pyelftools installed in the user location for site-packages?

What version of elftools do you have? Are you on 16.04? If not, please use cleanbuild.

a) I assume you are asking if it’s installed from CLI, or downloaded the source packages from Github ? in this case I am running from deb;

b) I think it is installed, according to:

alexandrum@Andu:~/.local/lib/python2.7/site-packages$ ls -l | grep elf drwxrwxr-x 6 alexandrum alexandrum 4096 iun 18 22:34 elftools drwxrwxr-x 2 alexandrum alexandrum 4096 iun 18 22:34 pyelftools-0.24.dist-info alexandrum@Andu:~/Desktop$ pip freeze --user | grep pyel pyelftools==0.24

c) elftools version: how can I obtain the version for this ?

d) I have Ubuntu 16.04.

e) used snapcraft cleanbuild, but it is getting me to nothing…aborted it after 10 minutes of waiting… :frowning:

Did you ever figure out what was causing this? I’m running into what looks like the same error.