fix: follow symlinks when copying license files - #2607
Open
wolfv wants to merge 6 commits into
Open
Conversation
When a `license_file` entry matched a symlink, `CopyDir` copied the symlink verbatim. If the link target was outside the glob-matched set (e.g. a license symlinked to `../../LICENSE`), the package ended up containing only a dangling symlink and the actual license content was lost. Add a `dereference_symlinks` option to `CopyDir` and enable it for license copying so symlinked licenses are materialized as real content. A broken symlink can no longer be silently packaged and now surfaces as a clear copy error. Fixes #2575 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Fcmrv6nQdGYURcZ3vB5vyh
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Fcmrv6nQdGYURcZ3vB5vyh
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Fcmrv6nQdGYURcZ3vB5vyh
Relying on the OS to follow a symlink during the copy fails on Windows for relative reparse targets. Resolve the link target ourselves (relative to the link's parent) and copy from the resolved path so a symlinked license is materialized as real content on all platforms. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Fcmrv6nQdGYURcZ3vB5vyh
Builds a recipe whose license_file is a symlink pointing outside the matched set and asserts the packaged license is real content, not a dangling symlink. This covers the packaging wiring that enables symlink dereferencing, which the copy_dir unit tests do not exercise. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Fcmrv6nQdGYURcZ3vB5vyh
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Fcmrv6nQdGYURcZ3vB5vyh
wolfv
force-pushed
the
claude/github-issue-2575-8a4boq
branch
from
June 30, 2026 15:45
52a823f to
0aa53ab
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This change adds support for dereferencing symlinks when copying license files, ensuring that symlinked licenses are packaged as actual content rather than potentially dangling symlinks.
Key Changes
dereference_symlinksfield toCopyDirstruct with a new builder method to enable the behaviorCopyDir::run()to skip symlink-specific processing when dereferencing is enabled, allowing the standard file/directory copy logic to follow and materialize symlink targetscopy_license_files()inpackaging.rsto enable symlink dereferencing for all three license file copy operations (work directory, recipe directory, and source directories)Implementation Details
When
dereference_symlinks(true)is set, symlinks are no longer copied as symlinks. Instead, the code falls through to the regular file/directory branches which useis_dir()andreflink_or_copy()- both of which follow symlinks. This approach:../LICENSE)The feature is disabled by default and only enabled for license file copying operations.
https://claude.ai/code/session_01Fcmrv6nQdGYURcZ3vB5vyh