Organize fails with an unhelpful error when attempting to overwrite a file
Metadata
Current evaluation
Closed as stale without a direct fix; the organize-overwrite failure was later fixed by merged PR #1370 (commit 7fe7c84e), ensuring the destination does not exist before moving files.
Resolution: closed stale
Reason: #1007 was closed as stale without a documented direct resolution. The same failure was fixed by merged PR #1370 in commit 7fe7c84e, addressing existing organize destinations.
Evaluated by: mr-cal-bot
No scores available.
Issue body
### Bug Description
If an `organize:` key attempts to use fileglobs to merge two files, this rather silly error is made:
```
❯ snapcraft pack
None
Detailed information: Error
```
### To Reproduce
Attempt to use a fileglob to organize a directory that already partially exists.
### part yaml
```shell
parts:
foo:
plugin: nil
organize:
# This globbing is important for the bug, it seems
"**/foo-lib/*": foo-lib
override-build: |
# Make a directory and a clone of it in $CRAFT_PART_INSTALL
mkdir foo-lib
mkdir $CRAFT_PART_INSTALL/foo-lib
# Populate the local version
touch foo-lib/bar
touch foo-lib/baz
# Only partially copy the destination
touch $CRAFT_PART_INSTALL/foo-lib/bar
```
### Relevant log output
```shell
2025-02-06 14:51:14.354 :: 2025-02-06 14:51:14.135 Traceback (most recent call last):
2025-02-06 14:51:14.354 :: 2025-02-06 14:51:14.135 File "/snap/snapcraft/13341/lib/python3.12/site-packages/craft_application/services/lifecycle.py", line 269, in run
2025-02-06 14:51:14.354 :: 2025-02-06 14:51:14.135 aex.execute(action, stdout=stream, stderr=stream)
2025-02-06 14:51:14.354 :: 2025-02-06 14:51:14.135 File "/snap/snapcraft/13341/lib/python3.12/site-packages/craft_parts/executor/executor.py", line 324, in execute
2025-02-06 14:51:14.354 :: 2025-02-06 14:51:14.135 self._executor.execute(actions, stdout=stdout, stderr=stderr)
2025-02-06 14:51:14.354 :: 2025-02-06 14:51:14.135 File "/snap/snapcraft/13341/lib/python3.12/site-packages/craft_parts/executor/executor.py", line 136, in execute
2025-02-06 14:51:14.354 :: 2025-02-06 14:51:14.135 self._run_action(act, stdout=stdout, stderr=stderr)
2025-02-06 14:51:14.354 :: 2025-02-06 14:51:14.135 File "/snap/snapcraft/13341/lib/python3.12/site-packages/craft_parts/executor/executor.py", line 211, in _run_action
2025-02-06 14:51:14.354 :: 2025-02-06 14:51:14.135 handler.run_action(action, stdout=stdout, stderr=stderr)
2025-02-06 14:51:14.354 :: 2025-02-06 14:51:14.135 File "/snap/snapcraft/13341/lib/python3.12/site-packages/craft_parts/executor/part_handler.py", line 171, in run_action
2025-02-06 14:51:14.354 :: 2025-02-06 14:51:14.135 state = handler(step_info, stdout=stdout, stderr=stderr)
2025-02-06 14:51:14.354 :: 2025-02-06 14:51:14.135 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-02-06 14:51:14.354 :: 2025-02-06 14:51:14.135 File "/snap/snapcraft/13341/lib/python3.12/site-packages/craft_parts/executor/part_handler.py", line 333, in _run_build
2025-02-06 14:51:14.354 :: 2025-02-06 14:51:14.135 self._organize(overwrite=update)
2025-02-06 14:51:14.354 :: 2025-02-06 14:51:14.135 File "/snap/snapcraft/13341/lib/python3.12/site-packages/craft_parts/executor/part_handler.py", line 882, in _organize
2025-02-06 14:51:14.354 :: 2025-02-06 14:51:14.135 organize_files(
2025-02-06 14:51:14.354 :: 2025-02-06 14:51:14.135 File "/snap/snapcraft/13341/lib/python3.12/site-packages/craft_parts/executor/organize.py", line 132, in organize_files
2025-02-06 14:51:14.354 :: 2025-02-06 14:51:14.135 shutil.move(src, dst)
2025-02-06 14:51:14.354 :: 2025-02-06 14:51:14.135 File "/snap/snapcraft/current/usr/lib/python3.12/shutil.py", line 884, in move
2025-02-06 14:51:14.354 :: 2025-02-06 14:51:14.135 raise Error("Destination path '%s' already exists" % real_dst)
```
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed stale | Closed as stale without a direct fix; the organize-overwrite failure was later fixed by merged PR #1370 (commit 7fe7c84e), ensuring the destination does not exist before moving files. | |
| stealth/space-bunny-alpha | — | closed stale | Closed as stale; the organize overwrite failure was later fixed by merged PR #1370 (commit 7fe7c84e), which removes an existing destination before moving files. | |
| stealth/space-bunny-alpha | — | closed stale | Closed as stale after no documented fix; later addressed by canonical/craft-parts#1370 (commit 7fe7c84e), preventing moves to existing destinations. | |
| qwen/qwen3.6-35b-a3b | — | — | Abandoned. The report highlights an unhelpful error when organize globs overwrite existing files. A simplified reproducer was provided, but no resolution or code changes were documented before closure. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without resolution. The report detailed a vague error when organize globs attempt to overwrite existing files. An internal Jira ticket was created, but no code changes or pull requests were merged to address the problem. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without resolution. Internal tracking was initiated via Jira CRAFT-4138, and a simplified reproducer was added. The unhelpful shutil error when organize attempts to overwrite existing files remains unresolved. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed without resolution. An internal ticket was created to track the unhelpful error when organize globs overwrite existing files, and a simplified reproducer was added. |
Update history
No update history recorded yet.
Related work
-
Likely Fixed By:
canonical/craft-parts#1370
(confidence 98%)
Merged commit 7fe7c84e ensures an organize destination is absent before moving files.
-
Related To:
canonical/craft-parts#1366
(confidence 90%)
A later issue describing the same existing-destination failure; it was also closed by PR #1370.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1370 fix: make sure the destination does not exist before organizing | craft-parts | merged | Merged PR #1370 as commit 7fe7c84e, removing any existing organize destination before moving files and fixing #1366/CRAFT-4870. | |
| #1366 Unhandled error when organizing a file to a directory where the file already exists | craft-parts | closed | Fixed by merged PR canonical/craft-parts#1370 (commit 7fe7c84e), which checks whether an organize destination exists before moving files. | |
| #1544 fix: prevent organizing a directory into itself | craft-parts | closed | PR #1544 was closed unmerged as incomplete; the solution was replaced by the organize-from-build rework in #1598 (commit cc02958b). | |
| #673 Organizing files fails if equivalent file already exists | craft-parts | closed | Organize collisions were fixed by PR #689 (commit c349e740), making organize_files() use part install directories instead of cwd-relative paths. |