Skip to content

fix: record actual link type in PrefixRecord#2169

Merged
baszalmstra merged 3 commits intoconda:mainfrom
ritankarsaha:fix/link-type-respects-filesystem-capabilities
Mar 6, 2026
Merged

fix: record actual link type in PrefixRecord#2169
baszalmstra merged 3 commits intoconda:mainfrom
ritankarsaha:fix/link-type-respects-filesystem-capabilities

Conversation

@ritankarsaha
Copy link
Copy Markdown
Contributor

Description

Fixes the TODO in installer/mod.rs that noted link_type: Some(LinkType::HardLink) was always
hardcoded.

Problem

PrefixRecord.link.link_type was always written as HardLink, even when:

  • hard links are impossible (cross-device, NFS, CIFS…)
  • the caller explicitly set LinkOptions { allow_hard_links: Some(false) }

The actual file linking via link_package_sync was already correct (it probes filesystem capability
and falls back to copies). Only the metadata recording was wrong.

Solution

  • Expose can_create_hardlinks_sync as pub(crate) so the installer can call it
  • Before moving install_options into link_package_sync, capture allow_hard_links
  • After linking, resolve the effective value (explicit option → filesystem probe)
  • Record HardLink when hard links were used, Copy otherwise

Fixes #2168

How Has This Been Tested?

Two new unit tests in installer::tests:

  • test_link_type_recorded_correctly — allow_hard_links: Some(false) → Copy in conda-meta
  • test_link_type_hardlink_when_forced — allow_hard_links: Some(true) → HardLink in conda-meta

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added sufficient tests to cover my changes.

Copy link
Copy Markdown
Collaborator

@baszalmstra baszalmstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe its nicer if this is just returned from link_package_sync instead? Instead of recomputing it?

@ritankarsaha
Copy link
Copy Markdown
Contributor Author

Maybe its nicer if this is just returned from link_package_sync instead? Instead of recomputing it?

Okaay looking into it now, and coming up with a fresh commit in a few.

@ritankarsaha
Copy link
Copy Markdown
Contributor Author

Maybe its nicer if this is just returned from link_package_sync instead? Instead of recomputing it?

Pushed a new commit now @baszalmstra , does it look good now ?

…dcoded HardLink

Signed-off-by: RITANKAR SAHA <ritankar.saha786@gmail.com>
…recomputing

Signed-off-by: RITANKAR SAHA <ritankar.saha786@gmail.com>
@ritankarsaha ritankarsaha force-pushed the fix/link-type-respects-filesystem-capabilities branch from ad8a129 to 7a18b20 Compare March 6, 2026 07:16
@ritankarsaha
Copy link
Copy Markdown
Contributor Author

@baszalmstra can you take a look into this ? FIxed the reviews.

@baszalmstra baszalmstra changed the title fix(install): record actual link type in PrefixRecord instead of hardcoded HardLink fix: record actual link type in PrefixRecord Mar 6, 2026
@baszalmstra baszalmstra merged commit 4e2c404 into conda:main Mar 6, 2026
18 checks passed
@github-actions github-actions Bot mentioned this pull request Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LinkType HardLink hardcoded in installer — ignores filesystem capabilities and LinkOptions

2 participants