Skip to content

fix: windows drive letters remap to unc paths#2104

Open
maxnbk wants to merge 6 commits into
AcademySoftwareFoundation:mainfrom
maxnbk:fix/windows-drive-letters-remap-to-unc-paths
Open

fix: windows drive letters remap to unc paths#2104
maxnbk wants to merge 6 commits into
AcademySoftwareFoundation:mainfrom
maxnbk:fix/windows-drive-letters-remap-to-unc-paths

Conversation

@maxnbk
Copy link
Copy Markdown
Contributor

@maxnbk maxnbk commented May 14, 2026

Closes #2045 and #1438 .
Partial but not complete fix for #1909 (Intentional, I feel that the work that was occurring in the gitbash PR would ultimately resolve this behavior?) .

Explanations:

os.path.realpath on Python 3.8+ Windows silently expands mapped drive letters to their underlying UNC paths. Because canonical_path calls realpath, FileSystemPackageRepository was storing a UNC self.location even when the caller supplied a drive-letter path. This caused make_resource_handle, which does a raw string comparison, to raise ResourceError on every drive-letter handle against a UNC-stored repository.

The fix:

On Windows, canonical_path now uses os.path.abspath instead of os.path.realpath. This preserves path style (drive-letter stays drive-letter, UNC stays UNC) and restores the pre-3.8 normalization behavior without a network-resolution side-effect. A make_resource_handle override is also added to the filesystem plugin to handle residual case or separator mismatches via canonical_path.

Extension of work:

A resolve_links_on_windows config flag (default False) has been added for sites that need some form of symlink/junction resolution on Windows. When enabled, a purpose-built _windows_realpath walks components of the path using os.readlink, resolving real symlinks without actually touching the drive root, in order to avoid the UNC-expansion side-effect entirely. Long-path support (\\?\ prefix handling) is included, with the relevant test skipped on hosts that do not have LongPathsEnabled=1 in the registry. Note: I'm aware that we need to move off of the winreg module, but since we have it for now, might as well use it.

Testing:

This was tested against an actual Drive-letter-map-with-matching-UNC-network-share .

Disclosure:

This PR was AI-assisted with Claude Code, Sonnet 4.6, primarily for diagnostics, logic-tracing, documentation and edge-case verification.

@maxnbk maxnbk requested a review from a team as a code owner May 14, 2026 19:50
@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

❌ Patch coverage is 80.85106% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.69%. Comparing base (d415b96) to head (1681466).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/rez/utils/filesystem.py 82.05% 3 Missing and 4 partials ⚠️
src/rez/rezconfig.py 0.00% 1 Missing ⚠️
src/rezplugins/package_repository/filesystem.py 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2104      +/-   ##
==========================================
+ Coverage   60.65%   60.69%   +0.04%     
==========================================
  Files         164      164              
  Lines       20584    20630      +46     
  Branches     3579     3593      +14     
==========================================
+ Hits        12485    12522      +37     
- Misses       7224     7228       +4     
- Partials      875      880       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

maxnbk added 4 commits May 14, 2026 16:00
…is remapped by rez to a UNC path

Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
…repository filesystem to ensure its consumption

Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
…-compatible symlink/junction-point resolution behavior

Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
…ion-behavior intended to produce realpath-like behavior

Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
@maxnbk maxnbk force-pushed the fix/windows-drive-letters-remap-to-unc-paths branch from ae4aeb2 to 92b2b07 Compare May 14, 2026 20:01
@maxnbk maxnbk added the devdays26 ASWF Dev Days 2026 label May 14, 2026
maxnbk added 2 commits May 14, 2026 16:36
…support in optional symlink-resolution for windows

Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
…ath-aware.

Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
@maxnbk maxnbk force-pushed the fix/windows-drive-letters-remap-to-unc-paths branch from 92b2b07 to 1681466 Compare May 14, 2026 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devdays26 ASWF Dev Days 2026

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: Repository mismatch with mounted network drives

1 participant