Multiple parts cannot organize to the same directory in the overlay
Metadata
Current evaluation
Fixed by merged PR canonical/craft-parts#1586 (commit 0797420f), allowing wildcard-organized overlay directories from multiple parts to merge despite metadata differences.
Resolution: closed resolved
Reason: PR #1586 was merged as commit 0797420f and closed #1487. It enables merging directory trees in the overlay while retaining strict errors for genuine file conflicts and metadata mismatches.
Evaluated by: mr-cal-bot
No scores available.
Issue body
### Bug Description
When pre-filling the overlay directory, the full directory trees from multiple parts that add to the overlay directory must be disjoint. If you try to put files into the same overlay directory from separate parts, craft-parts complains that the parent directory already exists.
### To Reproduce
1. Copy the part YAML below into `parts.yaml`
2. `mkdir /tmp/empty`
3. `sudo $(which python) -m craft_parts --verbose --overlay-base=/tmp/empty --partitions=default,other overlay`
### part yaml
```shell
parts:
part-a:
plugin: nil
override-build: |
mkdir $CRAFT_PART_INSTALL/my-dir
organize:
'*': (overlay)/
part-b:
plugin: nil
override-build: |
# This works
mkdir -p $CRAFT_PART_INSTALL/my-other-dir/subdir
# This fails.
mkdir -p $CRAFT_PART_INSTALL/my-dir/subdir
organize:
'*': (overlay)/
```
### Relevant log output
```shell
INFO:craft_parts.executor.executor:Installing build-packages
Execute: Pull part-a
Execute: Pull part-b
Execute: Overlay part-a
Execute: Build part-a (organize contents to overlay)
unknown argument ignored: lazytime
+ mkdir -p /home/lengau/Work/Code/craft-parts/parts/part-a/install/my-dir/subdir-a
Execute: Overlay part-b
Execute: Build part-b (organize contents to overlay)
unknown argument ignored: lazytime
+ mkdir -p /home/lengau/Work/Code/craft-parts/parts/part-b/install/my-other-dir/subdir-b
+ mkdir -p /home/lengau/Work/Code/craft-parts/parts/part-b/install/my-dir/subdir-b
Error: Failed to organize part 'part-b': trying to organize '*' to '(overlay)/', but '(overlay)/my-dir' already exists.
```
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Fixed by merged PR canonical/craft-parts#1586 (commit 0797420f), allowing wildcard-organized overlay directories from multiple parts to merge despite metadata differences. | |
| stealth/space-bunny-alpha | — | closed resolved | Fixed by merged PR canonical/craft-parts#1586 (commit 0797420f), allowing compatible wildcard-organized overlay directories to merge instead of failing. | |
| stealth/space-bunny-alpha | — | closed resolved | Fixed by merged PR #1586 (commit 0797420f): wildcard-organized overlay directories now merge across parts despite metadata differences. | |
| stealth/space-bunny-alpha | — | closed resolved | Fixed in canonical/craft-parts#1586 via commit 0797420f, which allows wildcard-organized overlay directories to merge despite metadata differences. | |
| stealth/space-bunny-alpha | — | closed resolved | Fixed by merging directories when organizing multiple parts into the overlay; organize.py was updated in commits 0797420f (#1586) and a1178308 (#1541). | |
| qwen/qwen3.6-35b-a3b | — | — | Closed and fixed. The bug was resolved by updating craft_parts/executor/organize.py to properly handle wildcard directory merging. | |
| qwen/qwen3.6-35b-a3b | — | — | Fixed by updating craft_parts/executor/organize.py to properly handle directory merging for wildcard-organized paths, resolving the conflict when multiple parts organize to the same overlay directory. | |
| qwen/qwen3.6-35b-a3b | — | — | Resolved after a contributor identified that organize.py handled wildcard directories too strictly, missing the existing directory-merge path. The bug was fixed and tracked via internal ticket CRAFT-5042. |
Update history
No update history recorded yet.
Related work
-
Likely Fixed By:
canonical/craft-parts#1586
(confidence 100%)
Merged resolving PR, implemented by commit 0797420f and explicitly associated with closing #1487.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1586 fix(organize): allow merging directories in overlay with metadata differences | craft-parts | merged | Merged as 0797420f, closing #1487. Final review changes tightened overlay directory conflict handling and retained strict errors for metadata mismatches. | |
| #1226 Organize content into the overlay | craft-parts | closed | Parts can organize content into the mounted overlay via merged PR #1254 (commit 0c806f20), shipped in craft-parts 2.22.0. | |
| #1611 Extra part triggering stage step before overlay step | craft-parts | closed | Fixed in canonical/craft-parts#1618 (18239b07): overlay-organized parts now build and organize before dependency staging, preventing fstab content from being missed. | |
| #1488 Organizing to the overlay directory is not idempotent | craft-parts | closed | Fixed by merged PR #1541 (commit a1178308), making organization into the overlay idempotent so rebuilds no longer fail on existing destination directories. | |
| #636 Filter out overlay directories if work dir and source dir are the same | craft-parts | closed | Fixed by merged PR canonical/craft-parts#1261 (commit 55d01a3f): local sources now exclude the overlay directory when source and work directories match. | |
| #1228 Reorder parts to prioritize organize to overlay | craft-parts | closed | Prioritized parts that organize overlays so installing overlay-package parts can use the prepared base; merged in canonical/craft-parts#1261 (55d01a3f). | |
| #689 fix(organize): use the part's install directories | craft-parts | merged | Merged craft-parts#689: organize_files now receives each part's install directories instead of recreating relative paths, ensuring organization uses base_dir rather than cwd. | |
| #1254 feat: allow parts to organize to overlay | craft-parts | merged | PR #1254 was merged, adding the (overlay) organize target to move part build files to the top of the mounted overlay stack (commit 0c806f20). | |
| #1735 Parts that organize to the overlay should not accept `overlay-script` or `override-overlay` | craft-parts | open | craft-parts accepts overlay-script/override-overlay on parts whose organize targets (overlay), silently doing the wrong thing. Triaged by lengau, assigned to randyli, and targeted by open PR #1747 adding PartSpec validation plus tests/docs. |