← Back to issue list

`charmcraft pack` retains no longer existing files from previous packs

View original Github issue

Metadata

Project
charmcraft
Number
#710
Type
issue
State
open
Author
sed-i
Labels
Status: Triaged Type: Bug
Created
Updated
Closed

Current evaluation

charmcraft pack includes files deleted from the working directory in the charm archive; clean fixes it. Triaged as a known bug, re-confirmed present in Oct 2024, upstream craft-parts bug filed, per-part clean workaround documented.

Suggested action: keep open

Reason: The issue is triaged (Status: Triaged, Type: Bug), explicitly confirmed as a known bug by maintainer facundobatista, and re-confirmed still present in Oct 2024 by lengau with an upstream report at canonical/craft-parts#851, which I verified is still open with a failing test awaiting implementation. The bug remains reproducible and relevant, so it should stay open until the craft-parts fix lands; the documented `charmcraft clean <part-name>` workaround mitigates but does not resolve it.

Impact: 45 Quick Win: 24.75 Staleness: 55 Complexity: 45 Confidence: 82 Support Request: 5

Issue body

When I repack a charm, the resulting charm has a file that no longer exists in the working directory: ``` > $ ls src/prometheus_alert_rules total 16K drwxrwxr-x 2 tux tux 4.0K Mar 10 15:00 . drwxrwxr-x 5 tux tux 4.0K Mar 10 15:00 .. -rw-rw-r-- 1 tux tux 323 Mar 10 15:00 always_firing_absent.rule -rw-rw-r-- 1 tux tux 301 Mar 10 15:00 always_firing_numeric.rule > $ charmcraft pack Charms packed: avalanche-k8s_ubuntu-20.04-amd64.charm > $ unzip -l avalanche-k8s_ubuntu-20.04-amd64.charm | grep always_firing 306 2021-12-01 19:21 src/prometheus_alert_rules/always_firing.rule 323 2022-03-10 20:00 src/prometheus_alert_rules/always_firing_absent.rule 301 2022-03-10 20:00 src/prometheus_alert_rules/always_firing_numeric.rule ``` Note how `src/prometheus_alert_rules/always_firing.rule` doesn't exist in the workdir, but is present in the archive. This issue went away after `clean`: ``` > $ charmcraft clean Cleaned project 'avalanche-k8s'. > $ charmcraft pack Charms packed: avalanche-k8s_ubuntu-20.04-amd64.charm > $ unzip -l avalanche-k8s_ubuntu-20.04-amd64.charm | grep always_firing 323 2022-03-10 20:00 src/prometheus_alert_rules/always_firing_absent.rule 301 2022-03-10 20:00 src/prometheus_alert_rules/always_firing_numeric.rule ``` ## Environment - Charmcraft 1.4.0 - lxd 4.23

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 45
Quick Win: 24.75
Staleness: 55
Complexity: 45
Confidence: 82
Support Request: 5
keep open charmcraft pack includes files deleted from the working directory in the charm archive; clean fixes it. Triaged as a known bug, re-confirmed present in Oct 2024, upstream craft-parts bug filed, per-part clean workaround documented.
qwen/qwen3.6-35b-a3b
Staleness: 65
Complexity: 45
Confidence: 85
Support Request: 10
keep open charmcraft pack includes deleted files from previous builds. Triaged bug, confirmed by maintainers, with an upstream craft-parts issue and a workaround. Last activity ~10 months ago.
qwen3.6-35b-a3b-mtp-q6
Staleness: 50
Complexity: 40
Confidence: 95
Support Request: 5
keep open charmcraft pack includes deleted files from previous builds. Triaged bug, confirmed active by maintainers, with an upstream fix tracked in craft-parts. Workaround available.
qwen3.6-35b-a3b-mtp-q6
Staleness: 65
Complexity: 45
Confidence: 85
Support Request: 10
keep open charmcraft pack retains deleted files from previous builds. Triaged bug confirmed still present in latest versions, with an upstream issue linked and a workaround documented.
qwen3.6-35b-a3b-mtp-q6
Staleness: 45
Complexity: 25
Confidence: 90
Support Request: 0
keep open charmcraft pack retains deleted files from previous builds in the output archive. Triaged bug confirmed still present in latest releases. Upstream issue filed in craft-parts. Workaround: run charmcraft clean <part-name> before repacking.

Update history

No update history recorded yet.

Related work

  • Blocked By: canonical/craft-parts#851 (confidence 85%)

    lengau filed this upstream bug (removed files from local sources remain in the part) on 2024-09-20; it is still open, so the charmcraft-side fix depends on it.

Related issues

Issue Project State Summary Similarity
#746 `charmcraft pack` for existing environment does not remove files that have been deleted charmcraft closed Closed as a duplicate of issue #710. The charmcraft pack command was reported to retain deleted files in the charm archive across builds. Resolution and tracking are handled in the referenced duplicate issue.
83%
#552 `charmcraft pack` runs indefinitely when using parts charmcraft closed The charmcraft pack hang was caused by a duplicate ignore patterns bug. This was fixed in Charmcraft 1.3.0. The author confirmed they would upgrade and close the issue pending recurrence.
79%
#1160 `charmcraft pack` does not recognize updated `charmcraft.yaml` file charmcraft open charmcraft pack ignores updated build-snaps channel in charmcraft.yaml without a clean; tracked as a craft-parts bug (canonical/craft-parts#496, still open) awaiting a dependency patch release to pull into charmcraft.
78%
#501 charmcraft pack fails trying to include a non-existing charm/src/.tox/ charmcraft closed charmcraft pack failed when copying non-existent build directories or files. Users worked around it with charmcraft clean. The issue was closed as fixed upstream in the underlying parts lifecycle code.
77%
#907 `charmcraft pack` does not handle updating a file's execution permissions without a `charmcraft clean` charmcraft open charmcraft pack ignores local file permission changes (e.g., chmod +x on src/charm.py) until a full charmcraft clean, causing confusing lint errors. Maintainer reproduced and filed upstream craft-parts#311; still unfixed.
76%
#2273 charmcraft.yaml deleted while packing (working tree not clean) charmcraft open charmcraft pack deletes charmcraft.yaml from the working tree, making git describe --dirty report -dirty on clean release builds. Reported with charmcraft 3.4.3, no maintainer response or labels in ~13 months.
76%
#1530 Changing charmcraft.yaml doesn't update the resulting charm's metadata.yaml charmcraft open Bug: editing charmcraft.yaml then re-running `charmcraft pack` does not update the resulting charm's metadata.yaml. Filed by a maintainer (lengau); last comment (2024-09-09) says it's unclear if still reproducible. Related open craft-application#821 describes the same 'Already packed' skip behavior.
74%
#821 5.5.0 changes pack semantics if the project file has different metadata craft-application open Charmcraft pack skips repacking when only charmcraft.yaml metadata (e.g. summary, config, platforms) changes, leaving a stale .charm. Triaged and moved to craft-application; workaround is clean. Conditional repacking support added in #1111.
73%
#514 `charmcraft build` silently omits files called out in `charmcraft.yaml` if executed from an external directory charmcraft closed Fixed in PR #525. Resolved a bug where charmcraft build and pack silently omitted glob-patterned files when run externally. The fix corrects path misalignment between Charmcraft and the parts processor, ensuring proper glob expansion.
72%
#693 Charms packed using the reactive plugin shows dirty version charmcraft closed Fixed by modifying the reactive plugin to stop removing charmcraft.yaml before building. This prevented git describe from incorrectly marking packed charm versions as dirty.
70%