Can't do two cleanbuilds at once

Sometimes I will run two snapcraft cleanbuild at the same time, usually because one is very long running, and while I wait for it to finish, I want to do something else. This breaks.

alan@hal:~$ snapcraft --version
snapcraft, version 2.33+git39.f820733
alan@hal:~$ lxd --version

Steps to reproduce

mkdir foo bar
cd foo
snapcraft init
cd ../bar
snapcraft init

Then in two terminals, run snapcraft cleanbuild a few seconds apart, one in ./foo and one in ./bar. One (the first one to be started) will finish successfully. The second will fail with the following issue:-

Looking up assertion ['account-key', 'public-key-sha3-384=BWDEoaqyr25nF5SNCvEv2v7QnM9QsfCc0PBMYD_i2NGSQ32EF2d4D0hqUel3m8ul']
Looking up assertion ['snap-declaration', 'snap-name=core']
Looking up assertion ['snap-revision', 'snap-revision=2462', 'snap-id=99T7MUlRhtI3U0QFgl5mXXESAiSwt776']
Adding assertion core_2462.assert
Installing /run/core_2462.snap
2017-08-28T17:37:42Z INFO cannot auto connect core:core-support-plug to core:core-support: (slot auto-connection), existing connection state "core:core-support-plug core:core-support" in the way
core 16-2.26.14 from 'canonical' installed
Stopping local:snapcraft-oversqueamishly-dispossessory-annmarie
Traceback (most recent call last):
  File "/snap/snapcraft/433/bin/snapcraft", line 11, in <module>
    load_entry_point('snapcraft==2.33', 'console_scripts', 'snapcraft')()
  File "/snap/snapcraft/433/usr/lib/python3.6/site-packages/pkg_resources/", line 565, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/snap/snapcraft/433/usr/lib/python3.6/site-packages/pkg_resources/", line 2631, in load_entry_point
    return ep.load()
  File "/snap/snapcraft/433/usr/lib/python3.6/site-packages/pkg_resources/", line 2291, in load
    return self.resolve()
  File "/snap/snapcraft/433/usr/lib/python3.6/site-packages/pkg_resources/", line 2297, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/snap/snapcraft/433/lib/python3.6/site-packages/snapcraft/cli/", line 19, in <module>
  File "/snap/snapcraft/433/lib/python3.6/site-packages/click/", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/snap/snapcraft/433/lib/python3.6/site-packages/click/", line 697, in main
    rv = self.invoke(ctx)
  File "/snap/snapcraft/433/lib/python3.6/site-packages/click/", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/snap/snapcraft/433/lib/python3.6/site-packages/click/", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/snap/snapcraft/433/lib/python3.6/site-packages/click/", line 535, in invoke
    return callback(*args, **kwargs)
  File "/snap/snapcraft/433/lib/python3.6/site-packages/snapcraft/cli/", line 188, in cleanbuild
    lifecycle.cleanbuild(project_options, remote)
  File "/snap/snapcraft/433/lib/python3.6/site-packages/snapcraft/internal/", line 357, in cleanbuild
    metadata=config.get_metadata(), remote=remote).execute()
  File "/snap/snapcraft/433/lib/python3.6/site-packages/snapcraft/internal/", line 140, in execute
  File "/snap/snapcraft/433/lib/python3.6/site-packages/snapcraft/internal/", line 185, in _inject_snapcraft
  File "/snap/snapcraft/433/lib/python3.6/site-packages/snapcraft/internal/", line 214, in _inject_snap
  File "/snap/snapcraft/433/lib/python3.6/site-packages/snapcraft/internal/", line 244, in _inject_assertions
    with open(filepath, 'wb') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/alan/snap/lxd/common/snapcraft.tmp/snapcraft_433.assert'

Looks to me like the “snapcraft.tmp” directory should have a generated name, not a static one.

1 Like

I’ve been meaning to write the same bug down! thank-you for beating me (quite hard with a bat?)…


Thanks for reporting this! I’ve never actually tried this myself before, but parallel builds should definitely work. I’m going to propose a fix shortly and look into a test case so this continues to work.

1 Like

Heres goes the PR as promised.

1 Like