`charmcraft build` silently omits files called out in `charmcraft.yaml` if executed from an external directory
Metadata
Current evaluation
Fixed by merged PR canonical/charmcraft#525 (merge commit 0d78f540), which runs the parts lifecycle from the project directory so relative globbed paths resolve during external builds.
Resolution: closed resolved
Reason: PR #525 was merged as 0d78f540 after maintainers identified mismatched working and project directories as the cause. The lifecycle now executes from the project directory, restoring relative glob expansion for external-directory builds.
Evaluated by: mr-cal-bot
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 |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Fixed by merged PR canonical/charmcraft#525 (merge commit 0d78f540), which runs the parts lifecycle from the project directory so relative globbed paths resolve during external builds. | |
| stealth/space-bunny-alpha | — | closed resolved | Fixed by PR canonical/charmcraft#525 ("parts: execute lifecycle from the project dir", CRAFT-505), merged as commit d0b28f48; parts lifecycle now runs in the project dir so relative dump sources and globbed prime filters resolve when building from elsewhere. | |
| stealth/space-bunny-alpha | — | closed resolved | Fixed globbed file inclusion for external-directory builds by running the parts lifecycle from the project directory; merged in #525 (0d78f540). | |
| 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. |
Update history
No update history recorded yet.
Related work
-
Likely Fixed By:
canonical/charmcraft#525
(confidence 100%)
Merged fix for CRAFT-505; implementation commit d0b28f48 and merge commit 0d78f540.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #198 `charmcraft init` would be better off with explicit directory name | charmcraft | closed | Kept directory selection on --project-dir; missing directories are now created by #508 (commit 15d530ae). | |
| #260 Can't include symlinked file into built charm | charmcraft | closed | Resolved by Charmcraft’s craft-parts build flow in PR #458 (implementation 437dab55, merge 9dc20872), enabling build-time handling of linked project files. | |
| #1930 `charmcraft pack -o` fails: `FileNotFoundError` | charmcraft | closed | Fixed by merged PR #2600 (commit 868da353): pack -p and -o paths are now applied outside the build container, preventing FileNotFoundError with custom output directories. | |
| #1616 Default `charm` or `bundle` part is not added if `parts` is defined but empty in `charmcraft.yaml`. | charmcraft | closed | Fixed by merged PR canonical/charmcraft#1815 (commit 2a0eb973), correcting default charm/bundle part handling in charmcraft.yaml. | |
| #2707 Charmcraft confuses the current directory with the project directory when both has a charmcraft.yaml | charmcraft | open | Charmcraft 4.2.1 mixed the CWD and -p project files when both had charmcraft.yaml, breaking nested pack builds and CI; targeted project-directory fixes are present in current code. | |
| #438 commands/build: output charms to cwd when using provider (CRAFT-359) | charmcraft | merged | Merged in canonical/charmcraft#438 via f73def1c, fixing provider builds to output charms in the current project directory and retrieve builds targeted outside it. | |
| #1079 Do not ignore symlinks to external files | charmcraft | closed | Symlinks to files outside the charm project were skipped during packing. Closed as resolved: PR #2836 (commit e06d40c1) added opt-in CHARMCRAFT_EXPERIMENTAL_MONOREPO, mounting the enclosing git repo root into the build instance; shipped in Charmcraft 4.5 with docs and spread tests. | |
| #287 `charmcraft build` failing if charm has manifest.yaml | charmcraft | closed | Builds stopped crashing on an existing manifest.yaml after Charmcraft added manifest validation and switched charm builds to clean directories. | |
| #249 `charmcraft build` will let you build a charm that won't deploy | charmcraft | closed | Closed by facundobatista as a duplicate, tracking all build-time sanity checks (incl. config.yaml/actions.yaml validity) in the umbrella issue charmcraft#27; later implemented by merged PR #556 (a585aec6). | |
| #416 Updated directory missing in `charmcraft` pull step | craft-parts | closed | Fixed skipped updated directories during Charmcraft PULL by merging craft-parts#417 (commit e7018745), which safely removes entries after iteration. |