← 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

Enhancement request to wrap the apt cache rmtree in _populate_stage_cache_dir with try/except and raise an actionable error when the cache cannot be removed (e.g. sudo then non-sudo destructive runs). Still open, untriaged, tracked as CRAFT-2937.

Suggested action: needs triage

Reason: The only comment is an automated Jira sync bot ('The internal ticket has been created: ... CRAFT-2937'), with no labels, no assignee, and no maintainer triage discussion — so despite being authored by maintainer mr-cal, it is uncategorized. I verified at current HEAD that craft_parts/packages/apt_cache.py:172 still calls `shutil.rmtree(cache_etc_apt_path)` with no try/except, and git log -S for 'PermissionError' and log searches for apt cache clear return no matching commits, so nothing has fixed it. The body pinpoints the exact file, line, mechanism (destructive mode run with sudo then without sudo), and the intended fix (wrap in try/except, add an error class in craft_parts/packages/errors.py which already has a clear PackagesError hierarchy), making it turnkey. Impact is moderate rather than high: it is a diagnostics/DX improvement, not an app-breaking or data-loss bug, and upstream snapcraft#4558 was closed as addressed in Snapcraft 8.14 via a non-root destructive-mode warning, which partially mitigates the user confusion but does not add the craft-parts error.

Evaluated by: mr-cal-bot

Impact: 35 Quick Win: 24 Complexity: 20 Confidence: 85 Actionability: 85

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
stealth/space-bunny-alpha
Impact: 35
Quick Win: 24
Complexity: 20
Confidence: 85
Actionability: 85
needs triage Enhancement request to wrap the apt cache rmtree in _populate_stage_cache_dir with try/except and raise an actionable error when the cache cannot be removed (e.g. sudo then non-sudo destructive runs). Still open, untriaged, tracked as CRAFT-2937.
qwen/qwen3.6-35b-a3b
Impact: 30
Quick Win: 15
Complexity: 30
Confidence: 70
Actionability: 70
keep open Feature request to wrap shutil.rmtree in apt_cache.py with try/except for better error messages when apt cache clearing fails.
qwen/qwen3.8-27b
Impact: 30
Quick Win: 24
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.

Update history

No update history recorded yet.

Related work

  • Related To: snapcraft#4558 (confidence 95%)

    Explicitly linked in the body as the originating request; closed as superseded by Snapcraft 8.14 adding a destructive-mode non-root warning via canonical/craft-application#974, so partially mitigated but not fixed at the craft-parts layer.

Related issues

Issue Project State Summary Similarity
#4558 Provide better errors for failures to clear the apt cache snapcraft closed Closed as superseded: Snapcraft 8.14 added a warning for destructive-mode runs as non-root (craft-application#974) instead of an apt-cache error; legacy apt_cache code later removed.
73%