lifecycle: automatically clean dirty steps
Metadata
Current evaluation
Merged in canonical/snapcraft#2145 (commit d033c7d0f), adding opt-in outdated_step_action=clean to rebuild changed lifecycle steps and resolve LP #1774021.
Resolution: closed resolved
Reason: PR #2145 was merged as commit d033c7d0f. It adds an opt-in Lifecycle.outdated_step_action=clean setting that cleans and reruns outdated steps, while preserving the existing default behavior.
Evaluated by: mr-cal-bot
No scores available.
Issue body
- [x] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [x] If this is a bugfix. Have you checked that there is a bug report open for the issue you are trying to fix on [bug reports](https://bugs.launchpad.net/snapcraft)?
- [x] If this is a new feature. Have you discussed the design on the [forum](https://forum.snapcraft.io)?
- [x] Have you successfully run `./runtests.sh static`?
- [x] Have you successfully run `./runtests.sh unit`?
-----
Currently the snapcraft CLI will error out if a given step has already run, but has changed since doing so (e.g. if a part has been pulled, but then had a `stage-package` added).
This PR resolves [LP: #1774021](https://bugs.launchpad.net/snapcraft/+bug/1774021) by adding support for automatically cleaning the required steps instead of erroring. It leaves today's behavior as the default, but adds a configuration item to enable the new behavior. Simply add the following snippet to `~/.config/snapcraft/cli.cfg`:
[Lifecycle]
outdated_step_action = clean
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Merged in canonical/snapcraft#2145 (commit d033c7d0f), adding opt-in outdated_step_action=clean to rebuild changed lifecycle steps and resolve LP #1774021. | |
| stealth/space-bunny-alpha | — | closed resolved | PR #2145 merged as commit d033c7d0f, adding auto-cleaning of outdated lifecycle steps behind a new config item (Lifecycle.outdated_step_action = clean) instead of erroring, fixing LP bug #1774021. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged as commit d033c7d0, adding opt-in Lifecycle.outdated_step_action=clean to rebuild changed lifecycle steps and resolve LP #1774021. | |
| qwen/qwen3.6-35b-a3b | — | — | Merged PR #2145 resolves LP: #1774021 by introducing an opt-in outdated_step_action = clean configuration. This automatically cleans dirty lifecycle steps instead of erroring, while keeping the original error behavior as the default. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged PR adds automatic cleaning of dirty lifecycle steps in snapcraft, resolving LP: #1774021. The behavior is disabled by default but can be enabled by setting outdated_step_action = clean in cli.cfg. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1647907 When a step is dirty, snapcraft doesn't autoclean and reexecute it | snapcraft (launchpad) | closed | Automatic cleanup and rebuilding of outdated lifecycle steps was implemented in canonical/snapcraft#2145 and merged as d033c7d0f. | |
| #1774021 Support automatically cleaning dirty steps | snapcraft (launchpad) | closed | Fixed by automatically cleaning dirty lifecycle steps in snapcraft PR #2145, merged as commit d033c7d0f. | |
| #1537786 lifecycle: allow do clean rebuild of all/parts without having to pull all again | snapcraft (launchpad) | closed | Added per-part, per-step clean commands via merged canonical/snapcraft PR #401 (88d21b180), allowing lifecycle rebuilds without recloning all sources. | |
| #1774260 Automatically clean and redo step if part is specified | snapcraft (launchpad) | closed | Explicitly named parts now clean and rerun the requested lifecycle step instead of being skipped; fixed by merged PR canonical/snapcraft#2152 (9d1407a85). | |
| #794 Improve lifecycle execution of steps | snapcraft | merged | Merged as commit f1ac5209f (snapcraft#794): lifecycle now runs steps in order using a list instead of a set, moving skip checks to runtime to speed up execution (LP #1590599). | |
| #1513 lifecycle: outdated step should raise SnapcraftError | snapcraft | merged | Merged PR #1513 in commit 141d7fdd7, updating lifecycle handling so outdated steps raise SnapcraftError derivatives. | |
| #1666366 Need --autoclean or similar | snapcraft (launchpad) | open | Requested opt-in automatic cleanup of stale lifecycle steps. The maintainer agreed with the opt-in approach, but current Snapcraft exposes no autoclean option or equivalent. | |
| #2286 config: change default outdated action to clean | snapcraft | merged | Merged in canonical/snapcraft#2286 via commit 2dbf7966f, changing base builds' default outdated action from error to clean and resolving LP #1793466. | |
| #2152 many: automatically redo step for specified part | snapcraft | merged | Merged as commit 9d1407a85 in snapcore/snapcraft. Specifying a part on the command line now cleans and re-runs that part's lifecycle step instead of skipping already-completed steps, fixing LP bug #1774260. | |
| #1007 lifecycle: clean without parsing if possible. | snapcraft | merged | Merged in snapcraft#1007 via commit bacf75dfe, allowing full clean operations to bypass snapcraft.yaml parsing unless part-specific cleanup is required. |