build providers: clean environment if project directory is changed
Metadata
Current evaluation
Merged into master. Fixes environment cleanup when project directories are relocated or reused. The build provider now tracks the directory path, verifies compatibility, and automatically cleans the environment on mismatch. Approved and passed CI.
Suggested action: —
No scores available.
Issue body
A common issue when a user moves/copies/relocates a project directory,
or re-uses the same project name.
Save the project directory location and verify it when checking
instance compatibility. If it doesn't match, clean the environment
prior to building.
Signed-off-by: Chris Patterson <chris.patterson@canonical.com>
- [ ] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [ ] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [ ] Have you successfully run `./runtests.sh static`?
- [ ] Have you successfully run `./runtests.sh tests/unit`?
-----
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Merged into master. Fixes environment cleanup when project directories are relocated or reused. The build provider now tracks the directory path, verifies compatibility, and automatically cleans the environment on mismatch. Approved and passed CI. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged into master. Build environment is now automatically cleaned when the project directory path changes or is reused. Directory location is saved and verified during compatibility checks to prevent stale state issues. 100% diff coverage. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #3216 build providers: tweak environment clean detection and logging | snapcraft | merged | Merged. Updated build environment cleaning detection and logging messages for accuracy and consistency. Refactored checks into a single _check_environment_needs_cleaning() function to consolidate clean_project() calls. Approved and merged by maintainer cjp256. | |
| #3105 build provider: clean incompatible build-environments | snapcraft | merged | Merged updates to clean incompatible build environments caused by base mismatches, missing base records, or version differences. Implemented Debian-compliant version comparison and updated test scenarios. Approved and merged. | |
| #2607 build providers: enforce well-known temp dir | snapcraft | merged | Merged into master to enforce a fixed temporary directory path for build providers, preventing copy failures when users configure non-standard temp directories. Approved by reviewer, passed CI, and resolves LP #1833292. | |
| #2225 build providers: environment setup for projects | snapcraft | merged | Merged. Adds a cloud data generator to the Base Provider for environment setup and updates project loading logic for re-execution mode. Integrates changes into the multipass provider. Resolves Launchpad issues #1782780 and #1782782. | |
| #3284 build providers: rename clean() -> clean_parts() to clarify scope | snapcraft | merged | Merged into master. Renames build provider clean() to clean_parts() to clarify scope, as cleanup extends beyond parts. Approved by one reviewer with 100% diff coverage and zero unresolved comments. | |
| #2374 build providers: destroy on create failures | snapcraft | merged | Merged. Resolves a bug where build providers and VMs remained running after launch failures. Adds cleanup logic and tests across seven files, approved by a reviewer and passing CI checks. | |
| #3951 providers: set environment according to directory inside instances | snapcraft | merged | Merged after approval and passing CI. Sets environment variables based on the directory inside instances to enable manual part building during debugging. Increased overall coverage by 0.01%. | |
| #3929 providers: refactor clean_project_environments | snapcraft | merged | Merged a refactor to the craft-providers interface, removing get_instance_name() from clean_project_environments() and renaming is_provider_available() to is_provider_installed(). Aligns with rockcraft, passed CI, and increased coverage by 0.13%. | |
| #2964 build providers: remove LXD specific env setup | snapcraft | merged | Merged. Removes LXD-specific environment setup from build providers since Provider._get_env_command already handles it. Approved by reviewer, passed CI, and successfully integrated. | |
| #2474 build providers: remove dead code | snapcraft | merged | Merged removal of dead code for legacy cleanbuild support in build providers. Approved by one reviewer, passed CI, and modified three files (+54/-165 lines). |