Proposal: snapcraft rebuild


Currently when working with a large snap that has multiple parts in different directories of the source tree, and multiple folders change, and I go to run snapcraft, snapcraft will tell me that some parts are out of date (and they are), and so then I need to type or copy the parts that are dirty into another command and then run

snapcraft clean <list-of-parts> && snapcraft

It would be nice if there was a command that did both of these steps for me, first running snapcraft clean part on all the dirty parts, and then running snapcraft afterwards. Sort of like a cleanbuild, but not really. Strawman proposal:

snapcraft rebuild


1 Like

Take a look at the “lifecycle” section under “base” in the release notes for 2.43, and you’ll see a switch you can flip to get snapcraft doing that for you on its own when you run build again. It’s still a little beta, but it works pretty well (although some fixes have landed since the latest stable release, so you might consider using edge if you run into issues with it).

1 Like

That sounds like exactly what I’m looking for, thanks!
On a side-note, other than the snapcraft code itself is there documentation for the ~/.config/snapcraft/cli.cfg file I keep hearing about? It seems like there are some useful features being added there…

Not really, no. It’s mostly where we put feature flags, i.e. experimental things you can opt-in-to, which we spread by word-of-mouth (or fingers, as the case may be). This particular behavior will be the default for snapcraft 3.0.

1 Like

For snapcraft 3.0 when using bases that is.

1 Like

Indeed, thank you for the clarification.

FYI, I’ve written a blog post with some hints about how to speed up snap development.


That’s an excellent blog post!

1 Like

Hi @kyrofa , I tried to use your guide, but I don’t seem able to clean just a single stage. Has the command changed?

Skipping pull quack (already ran)
Skipping build quack (already ran)
Skipping stage quack (already ran)
Skipping prime quack (already ran)
'grade' property not specified: defaulting to 'stable'.
Determining the version from the project repo (version: git).
The version has been set to '0+git.c67d033-dirty'
The requested action has already been taken. Consider
specifying parts, or clean the steps you want to run again.
$ snapcraft clean quack --use-lxd --step=build
Usage: snapcraft clean [OPTIONS] <part>...
Try 'snapcraft clean -h' for help.

Error: No such option: --step (Possible options: --help, --shell)

However the previous message implied it was possible in some way :thinking:

Consider specifying parts, or clean the steps you want to run again.

I’m afraid that blog post is tremendously out of date with the move to build VMs/containers. That particular issue sounds like it might be this bug though, which is fixed by this PR:

Hi and thanks for your quick reply :blush: I’m not sure it’s the same bug, as I can specify the part, but I can’t specify the stage.

E.g. snapcraft clean quack --use-lxd works, but snapcraft clean quack --step=build --use-lxd doesn’t :confused: I’d like to keep the pull part, which takes time due to pulling and installing packages but redo the following stages :blush:

Ah yes, I seem to remember the maintainers opting to drop that particular capability. @sergiusens, @cjp256 can you speak to this?

We’re trying to improve Snapcraft on incremental rebuilding workflows. Core20 improved some things and we’ve identified other areas for improvement to tackle.

Can you share a little bit about your workflow and what you are trying to accomplish?