← Back to issue list

`charmcraft build` silently omits files called out in `charmcraft.yaml` if executed from an external directory

View original Github issue

Metadata

Project
charmcraft
Number
#514
Type
issue
State
closed
Author
ca-scribner
Labels
Created
Updated
Closed

Current evaluation

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.

Suggested action:

No scores available.

Issue body

I'm finding some unexpected behaviour around specifying files to be copied into a charm via `charmcraft.yaml` and the execution directory when building/packing. # Working examples ## Specifying an exact file and executing `charmcraft` from the charm dir Doing: ``` BASE=/tmp/charmcraft-file-copy mkdir -p $BASE cd $BASE charmcraft init mkdir to_copy touch to_copy/foo cat << EOF > charmcraft.yaml type: charm parts: copy_files: plugin: dump source: ./ source-type: local prime: - ./to_copy/foo EOF charmcraft build -f . ``` produces `.charm` file that includes the `./to_copy/foo` as specified in the `charmcraft.yaml`. ## Specifying an exact file and executing `charmcraft` from some other dir This also works if you execute `charmcraft` from another directory, eg: ``` # (continue from previous example) cd /tmp charmcraft build -f $BASE ``` ## Specifying a file pattern and executing `charmcraft` from the charm dir Doing: ``` BASE=/tmp/charmcraft-file-copy mkdir -p $BASE cd $BASE charmcraft init mkdir to_copy touch to_copy/foo cat << EOF > charmcraft.yaml type: charm parts: copy_files: plugin: dump source: ./ source-type: local prime: - ./to_copy/* # <--NOTE: using pattern EOF charmcraft build -f . ``` also works as expected # Broken example ## Specifying a file pattern and executing `charmcraft` from some other dir If we execute the previous example (with pattern for files) from a different directory, eg: ``` # (continue from previous example) cd /tmp charmcraft build -f $BASE ``` we encounter no errors, but we also **do not** have the requested files in the `.charm` file. We see the same problem using `charmcraft pack -p ...`. My expectation would be that this pattern should work, but also if for some reason it cannot copy the files that it would break loudly rather than silently.

Evaluation history

Date Model Scores Action Summary
qwen3.6-35b-a3b-mtp-q6 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.
qwen/qwen3.6-35b-a3b Fixed in PR #525. Charmcraft build and pack silently omitted globbed files from charmcraft.yaml when run externally due to a path resolution mismatch. The fix aligns directory handling to ensure correct file inclusion.
qwen/qwen3.6-35b-a3b Fixed in PR #525. Resolved a path resolution mismatch causing charmcraft build and pack to silently omit wildcard-patterned files when executed from an external directory. The update aligns project directory handling with the parts processor to ensure correct file inclusion.
qwen3.6-35b-a3b-mtp-q6 Fixed in PR #525. Charmcraft build and pack silently dropped glob patterns in charmcraft.yaml when executed externally due to a path resolution mismatch. The update corrects project directory alignment between Charmcraft and the parts processor.
qwen3.6-35b-a3b-mtp-q6 charmcraft build and pack silently omitted globbed files from charmcraft.yaml when executed from an external directory due to a path resolution mismatch. Resolved in PR #525, which corrected project directory handling for relative sources.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#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.
72%
#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.
72%
#634 Build does not include files or directories charmcraft closed Closed as not a bug. The reporter discovered that since charmcraft 1.2.0, files must be explicitly listed in the charmcraft.yaml prime section to be included in builds. Resolved by updating the configuration, not a code fix.
72%
#710 `charmcraft pack` retains no longer existing files from previous packs charmcraft 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.
72%
#287 `charmcraft build` failing if charm has manifest.yaml charmcraft closed charmcraft build crashed when a pre-existing manifest.yaml conflicted with machine-generated builds introduced in PR #281. Fixed in master by validating manifest.yaml and using clean build directories to prevent conflicts and crashes.
71%
#416 Updated directory missing in `charmcraft` pull step craft-parts closed Closed and resolved by fixing in-place list modification during iteration in craft_parts/sources/local_source.py. This corrected directory tracking during the charmcraft pull step, preventing build failures.
70%