← Back to issue list

Organizing files fails if equivalent file already exists

View original Github issue

Metadata

Project
craft-parts
Number
#673
Type
issue
State
open
Author
dilyn-corner
Labels
Created
2024-02-27 23:09:32+00:00
Updated
2025-03-11 14:28:35+00:00
Closed

Current evaluation

No evaluation has been recorded for this issue yet.

Issue body

### Bug Description When a `part` defines an `organize:` which includes moving a file into a (not `default`) component partition, the organize will fail just in case the file already exists in that partition. This behavior breaks from how that functionality works when not organizing into a component, where the collision of identical files is ignored. This problem only seems to impact organizing into a partition which isn't `default`. To see this, remove the `organize:` from `my-part` in the below `snapcraft.yaml` and run `snapcraft build my-part --verbose` twice. It should not fail. I would expect the behavior to match regardless of the name of the partition the file is being organized into. ### To Reproduce Install snapcraft from a feature branch and create a boilerplate snap: ``` snap switch --channel=latest/edge/components snapcraft; snap refresh snapcraft # Tested with revision 10677 mkdir test; cd test; snapcraft init ``` Create some simple files: ``` mkdir src/ touch src/default-file src/foo-file ``` Use the below `snapcraft.yaml` and run `snapcraft build my-part --verbose` twice. To compare the behavior when not organizing into a component not named `default`, remove the `organize` section. To compare the behavior when not using components, remove the `components:` section and the usage of `organize:`. Both of these comparisons should succeed, while the provided example fails. ### part yaml ```shell name: my-snap-name # you probably want to 'snapcraft register <name>' base: core24 # the base snap is the execution environment for this snap build-base: devel version: '0.1' # just for humans, typically '1.2+git' or '1.3.2' summary: Single-line elevator pitch for your amazing snap # 79 char long summary description: | This is my-snap's description. You have a paragraph or two to tell the most important story about your snap. Keep it under 100 words though, we live in tweetspace and your description wants to look good in the snap store. grade: devel # must be 'stable' to release into candidate/stable channels confinement: devmode # use 'strict' once you have the right plugs and slots parts: my-part: plugin: dump source: src/ organize: foo-file: (component/foo)/foo-file components: foo: type: test summary: test description: test ``` ### Relevant log output ```shell dilyn@Ares:~/test -> snapcraft build my-part --verbose Starting snapcraft Logging execution to '/home/dilyn/.local/state/snapcraft/log/snapcraft-20240227-175558.077912.log' Starting snapcraft Logging execution to '/home/dilyn/.local/state/snapcraft/log/snapcraft-20240227-175558.077912.log' deleting current features configuration Running on amd64 for amd64 Running snapcraft with a devel instance is for testing purposes only. Launching instance... Creating instance from base instance Starting instance \ (11.7s) Starting instance \ (14.1s) Starting instance Starting snapcraft Logging execution to '/root/.local/state/snapcraft/log/snapcraft-20240227-175622.766916.log' Starting snapcraft Logging execution to '/root/.local/state/snapcraft/log/snapcraft-20240227-175622.766916.log' deleting current features configuration Running on amd64 for amd64 Initializing parts lifecycle Installing build-packages Installing build-snaps Pulling my-part Building my-part :: + cp --archive --link --no-dereference . /root/parts/my-part/install/default dilyn@Ares:~/test -> snapcraft build my-part --verbose Starting snapcraft Logging execution to '/home/dilyn/.local/state/snapcraft/log/snapcraft-20240227-175642.418888.log' Starting snapcraft Logging execution to '/home/dilyn/.local/state/snapcraft/log/snapcraft-20240227-175642.418888.log' deleting current features configuration Running on amd64 for amd64 Running snapcraft with a devel instance is for testing purposes only. Launching instance... Starting instance Starting snapcraft Logging execution to '/root/.local/state/snapcraft/log/snapcraft-20240227-175653.254644.log' Starting snapcraft Logging execution to '/root/.local/state/snapcraft/log/snapcraft-20240227-175653.254644.log' deleting current features configuration Running on amd64 for amd64 Initializing parts lifecycle Installing build-packages Installing build-snaps Skipping pull for my-part (already ran) Rebuilding my-part (requested step) :: + cp --archive --link --no-dereference . /root/parts/my-part/install/default Failed to organize part 'my-part': trying to organize file 'foo-file' to '(component/foo)/foo-file', but '(component/foo)/foo-file' already exists. Failed to execute build in instance. Recommended resolution: Run the same command again with --debug to shell into the environment if you wish to introspect this failure. Full execution log: '/home/dilyn/.local/state/snapcraft/log/snapcraft-20240227-175642.418888.log' ```

Evaluation history

No evaluation history available.