← Back to issue list

Provide visible yaml settings or document organize plugin behavior for directory merging

View original Launchpad issue

Metadata

Project
snapcraft (launchpad)
Number
#1669908
Type
issue
State
open
Author
~dmitriis
Labels
Created
Updated
Closed

Current evaluation

Request to document or expose a snapcraft.yaml knob for the organize plugin's directory-merging behavior, after a cryptic 'path ./ already exists' error from shutil.move when using '*' keys. No labels, no maintainer response, 0 comments; last activity 47 days ago on a ~9.5-year-old issue.

Suggested action: needs triage

Reason: The issue has no labels, no assignee, and zero comments — no sign a maintainer has assessed it, so it needs triage. It is a documentation/UX request (make organize's directory-merge precedence visible) rather than a hard bug, and the reporter already found a workaround (avoiding '*'), which lowers urgency. The referenced code paths (snapcraft/internal/pluginhandler, file_utils.link_or_copy_tree) predate the current snapcraft/parts layout, so a triager should confirm whether the behavior still applies before deciding to document or close.

Impact: 30 Quick Win: 16.5 Staleness: 55 Complexity: 45 Confidence: 55 Support Request: 35

Issue body

Hi, I was working on a change for snap-libvirt and encountered a behavior which is not apparent on the first sight. https://github.com/openstack-snaps/snap-libvirt/commit/8cd9af031a9b01f360975bddc1964e9380b983e6 Originally '*' has been used in the organize plugin which lead to an error due to the fact that the directory structure used by both parts (libvirt and qemu) is similar: "path ./ already exists" This error is cryptic unless you look at the source code of snapcraft: def _organize: https://github.com/snapcore/snapcraft/blob/9e00ffc151b46026b414c8b4b8e44a3a9d4c0b75/snapcraft/internal/pluginhandler/__init__.py#L449 calls def _organize_filesets(fileset, base_dir): https://github.com/snapcore/snapcraft/blob/9e00ffc151b46026b414c8b4b8e44a3a9d4c0b75/snapcraft/internal/pluginhandler/__init__.py#L907 Now this function has 3 code paths: def _organize_filesets(fileset, base_dir):     for key in sorted(fileset, key=lambda x: ['*' in x, x]):         src = os.path.join(base_dir, key)         dst = os.path.join(base_dir, fileset[key])         sources = iglob(src, recursive=True)         for src in sources:             if os.path.isdir(src) and '*' not in key: # <---- first                 file_utils.link_or_copy_tree(src, dst)                 # TODO create alternate organization location to avoid                 # deletions.                 shutil.rmtree(src)             elif os.path.isfile(dst): # <----- second                 raise EnvironmentError(                     'Trying to organize file {key!r} to {dst!r}, '                     'but {dst!r} already exists'.format(                         key=key, dst=os.path.relpath(dst, base_dir)))             else: # <----- third                 os.makedirs(os.path.dirname(dst), exist_ok=True)                 shutil.move(src, dst) The third code path is what gets picked in case there is a '*' in the key and the destination in not a file. shutil.move is the call that gave 'path ./ already exists' error which I learned by grepping cpython source code: def move function https://hg.python.org/cpython/file/2.7/Lib/shutil.py#l306 Now, looking at an alternative code path (the first one) which calls link_or_copy_tree I see: https://github.com/snapcore/snapcraft/blob/05ba34a324c781f3e454d88f88267c5356771f9a/snapcraft/file_utils.py#L93 def link_or_copy_tree(source_tree, destination_tree,                       copy_function=link_or_copy):     """Copy a source tree into a destination, hard-linking if possile.     :param str source_tree: Source directory to be copied.     :param str destination_tree: Destination directory. If this directory                                  already exists, the files in `source_tree` will take precedence. The destination_tree argument gives a very good description in terms of what is going to happen but it is "hidden" in the source code which forces a regular snapcrafter to do some grepping. Avoiding '*' helped me to select the right code path but it would be nice to have more visibility for that (either in a form of a knob in snapcraft.yaml or in the docs). Thanks!

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 30
Quick Win: 16.5
Staleness: 55
Complexity: 45
Confidence: 55
Support Request: 35
needs triage Request to document or expose a snapcraft.yaml knob for the organize plugin's directory-merging behavior, after a cryptic 'path ./ already exists' error from shutil.move when using '*' keys. No labels, no maintainer response, 0 comments; last activity 47 days ago on a ~9.5-year-old issue.
qwen/qwen3.6-35b-a3b
Staleness: 95
Complexity: 10
Confidence: 85
Support Request: 20
needs triage Request to document or add YAML configuration for the snapcraft organize plugin's directory merging behavior, which currently causes cryptic errors when using wildcards. Untriaged, no maintainer response.
qwen/qwen3.6-35b-a3b
Staleness: 88
Complexity: 25
Confidence: 85
Support Request: 20
close stale Request to document or add YAML configuration for the organize plugin directory merging behavior, which causes cryptic errors when paths conflict. Unlabelled, no maintainer response, open for nearly a decade.
qwen3.6-35b-a3b-mtp-q6
Staleness: 100
Complexity: 10
Confidence: 90
Support Request: 5
close stale Request to document or add YAML configuration for the organize plugin's directory merging behavior, which currently causes cryptic errors when using wildcards. Unaddressed for over 9 years.
qwen3.6-35b-a3b-mtp-q6
Staleness: 98
Complexity: 20
Confidence: 90
Support Request: 25
close stale Document or expose YAML settings for the snapcraft organize plugin directory merging behavior to prevent cryptic errors. Open, unassigned, and inactive for over 9 years.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#1844801 Organize has different move behavior when using wildcard snapcraft (launchpad) open Snapcraft organize keyword moves directory contents for literal paths but the directory itself for glob/wildcard paths, causing confusing 'already exists' errors. No maintainer response in 7 years; behavior still present in craft-parts organize code. Needs triage.
72%