← Back to issue list

Provide better errors for failures to clear the apt cache

View original Github issue

Metadata

Project
craft-parts
Number
#648
Type
issue
State
open
Author
mr-cal
Labels
Created
Updated
Closed

Current evaluation

Request to wrap the apt-cache cleanup in craft_parts/packages/apt_cache.py with try/except to emit a clearer error when the cache cannot be removed (e.g. destructive mode run with sudo then without). Unlabeled, no maintainer response; related snapcraft issue closed as superseded by craft-application#974.

Suggested action: needs triage

Reason: No labels, no assignee, and the only comment is the Jira-sync bot (CRAFT-2937), so no maintainer has assessed it. The referenced block (shutil.rmtree of cache_etc_apt_path in _populate_stage_cache_dir) is still unguarded in current code, though craft-application#974 now warns on non-root destructive runs, mitigating the original trigger.

Impact: 30 Quick Win: 24.0 Staleness: 65 Complexity: 20 Confidence: 70 Support Request: 10

Issue body

### What needs to get done See: https://github.com/snapcore/snapcraft/issues/4558 Craft-parts should provide a better error for when the apt-cache cannot be removed. This can be done by wrapping [this block](https://github.com/canonical/craft-parts/blob/bd6c687f30dc72346816d7cd0b4ceabc8e530d92/craft_parts/packages/apt_cache.py#L166) with a try/except and providing a useful and actionable error message. ### Why it needs to get done If a craft app is run in destructive mode with sudo then without sudo, the error message doesn't explain the problem or help the user figure out how to clean their cache.

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 30
Quick Win: 24.0
Staleness: 65
Complexity: 20
Confidence: 70
Support Request: 10
needs triage Request to wrap the apt-cache cleanup in craft_parts/packages/apt_cache.py with try/except to emit a clearer error when the cache cannot be removed (e.g. destructive mode run with sudo then without). Unlabeled, no maintainer response; related snapcraft issue closed as superseded by craft-application#974.
qwen/qwen3.6-35b-a3b
Staleness: 85
Complexity: 15
Confidence: 80
Support Request: 10
needs triage Enhancement request to improve error messages when apt-cache removal fails during destructive mode operations. Open for ~2.5 years with no maintainer labels, assignment, or response.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 20
Confidence: 80
Support Request: 10
needs triage Enhancement to improve error messages when apt cache clearing fails, particularly in destructive mode. Untriaged, unlabelled, and inactive for over a year.
qwen3.6-35b-a3b-mtp-q6
Staleness: 82
Complexity: 12
Confidence: 78
Support Request: 5
keep open Add actionable error handling when Craft-parts fails to clear the apt cache, resolving destructive mode permission issues. Currently open, unassigned, untriaged, and stale with no recent activity.

Update history

No update history recorded yet.

Related work

  • Related To: canonical/snapcraft#4558 (confidence 90%)

    Explicitly referenced in the issue body; closed as superseded by craft-application#974, which warns when running destructive mode without root.

  • Related To: canonical/craft-parts#1194 (confidence 60%)

    fix: correct file permissions for the apt cache — addresses permission-related apt cache problems, though not the error-message improvement requested here.

Related issues

Issue Project State Summary Similarity
#4558 Provide better errors for failures to clear the apt cache snapcraft closed Superseded by snapcraft 8.14, which now warns when running destructive mode as a non-root user. The related improvement was merged in canonical/craft-application#974, providing clearer guidance for cache permission issues.
83%
#3528 apt cache: improve error handling when packages do not have candidates available (CRAFT-136) (CRAFT-218) snapcraft merged Merged apt cache error handling that adds null checks for package candidates, preventing crashes when versions are unavailable. The change raises a clear PackageNotFoundError and optimizes unmarking logic, resolving multiple internal bug reports.
76%