Skip to content

Fix UNC lookup and relative path handling - #4914

Merged
bdbaddog merged 10 commits into
SCons:masterfrom
Boulea7:oss/scons-4911-unc-v16
Oct 18, 2026
Merged

bdbaddog merged 10 commits into
SCons:masterfrom
Boulea7:oss/scons-4911-unc-v16

Conversation

@Boulea7

@Boulea7 Boulea7 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Handle both separator styles in Windows UNC lookups, including FindFile and UNC top directories. Return absolute paths when relative paths cross Windows drives or UNC shares.
  • Add host-native install/package staging regressions: POSIX paths with two leading slashes retain their directory components, and Windows UNC expectations follow native ntpath behavior.
  • Isolate three synthetic UNC path tests from disk metadata checks, restoring the checker in each finally block. Keep the original path assertions.

CHANGES.txt, RELEASE.txt, and the relpath documentation describe the resulting behavior. Original contributor notes are retained.

Validation

On Linux, Python 3.11.2 and 3.13.5 pass the focused filesystem, util, and warnings unit files plus four related CLI tests. Each run covers 126 unit cases: 3.11 has 3 Windows-only skips; 3.13 additionally skips one optional-psutil test. Guard checks run all three affected methods, retain their five path assertions, reject synthetic UNC metadata I/O, and verify state restoration after injected failures.

python3 -B runtest.py SCons test testing --time --jobs=8 selected 1310 scripts: 1067 passed, 1 failed, and 242 returned NO_RESULT (221 seconds, exit 1). The sole failure, test/TEX/variant_dir_newglossary.py, reports missing test.ist and test.nto. It also reproduces on unmodified eb0b065 in the same environment; its root cause is not established here. NO_RESULT is not counted as a pass.

Both diff checks pass. FSTests has the same 92 existing Ruff diagnostics as eb0b065, with none added. Local validation did not cover native Windows, macOS, real UNC share I/O, or Python 3.9/3.14.

This implementation and its tests were developed with OpenAI Codex assistance.

Contributor Checklist:

  • I have created a new test or updated the unit tests to cover the new/changed functionality.
  • I have updated CHANGES.txt and RELEASE.txt (and read README.rst).
  • I have updated the appropriate documentation.

Normalize native UNC separators and start on-disk file lookups at a complete
share while preserving the existing UNC root and derived-file lookup.
Return absolute paths across Windows drives or UNC shares, and preserve
nested UNC install and package locations beneath POSIX staging roots.

Replace the expected-failure UNC regressions with passing coverage,
including public FindFile and install-sandbox tests. Update the reference
documentation and release notes.

Related SCons#4911.

Signed-off-by: boulea7 <zln1905391059@163.com>
Assisted-by: OpenAI Codex
@mwichmann

Copy link
Copy Markdown
Collaborator

I had a potential patchset for this as well, will take me a bit of time to compare approaches, etc. A choice was made to initially just record the problems (tests, github issue).

@Boulea7
Boulea7 marked this pull request as ready for review October 1, 2026 22:11
Comment thread CHANGES.txt Resolved
Assisted-by: OpenAI Codex
Signed-off-by: boulea7 <zln1905391059@163.com>
@bdbaddog

Copy link
Copy Markdown
Contributor

I'm fairly certain we should only be handling UNC paths on windows computers.
Paths like this are valid on macOS and are not UNC paths, but your logic would interpret them as such?

% ls //Users/bdbaddog/.bashrc
//Users/bdbaddog/.bashrc

The new branch of make_path_relative assumes any string starting with //name/name/ is a Windows UNC path (//server/share/...), and it does so on every platform.

On POSIX that assumption is wrong. A leading // is just a redundant slash, so //Users/bdbaddog/.bashrc is the same file as /Users/bdbaddog/.bashrc. Users and bdbaddog are ordinary directories, not a server and share. The code removes them anyway, so the function returns .bashrc instead of Users/bdbaddog/.bashrc.

The result is that an Install destination with a doubled leading slash lands in the wrong place under --install-sandbox. It fails silently, with no error, and it changes behavior that worked on origin/master.

The fix is to apply the UNC rule only when the path really is Windows-style, meaning a Windows host or backslash separators. Plain // paths on POSIX should fall through to the old behavior.

Please update your code so that UNC decoding only applies on windows.

Restore host-native path handling for install and package locations. Keep
POSIX directory components intact and leave Windows UNC parsing to the
native path implementation.

Cover doubled-leading-slash destinations and Python 3.13 Windows path
semantics in the regressions.

Assisted-by: OpenAI Codex
Signed-off-by: boulea7 <zln1905391059@163.com>
@Boulea7

Boulea7 commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Removed the cross-platform UNC branch and restored native os.path.splitdrive() handling in c8a5f11. On POSIX, //Users/user/.bashrc now keeps Users/user/.bashrc under the staging root, and backslashes remain literal filename characters. Added regression coverage for the path mapping and installed file contents. The affected unit tests and four related CLI tests pass on Linux; the three Windows-only unit tests remain skipped locally.

@mwichmann

Copy link
Copy Markdown
Collaborator

I'm fairly certain we should only be handling UNC paths on windows computers. Paths like this are valid on macOS and are not UNC paths, but your logic would interpret them as such?

% ls //Users/bdbaddog/.bashrc
//Users/bdbaddog/.bashrc

If we're going to go this route (I disagree, but can tell I'd lose the argument), we should at least do something with the alternate form of UNC paths: \\?\UNC\ - that's pretty sure never to map to anything valid on a POSIX-style system. If we don't handle UNC on non-Windows that ought to error/warn/something.

Emit the default windows-extended-unc warning when POSIX filesystem
lookup or FindFile encounters the canonical extended-UNC prefix. Paths
remain literal and Windows extended-UNC semantics are not normalized.

Adjust bare-UNC-root test expectations to follow native ntpath.isabs
behavior, and cover warning suppression and warning-as-exception handling.

Assisted-by: OpenAI Codex
Signed-off-by: boulea7 <zln1905391059@163.com>
@Boulea7

Boulea7 commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Non-Windows SCons filesystem lookup and FindFile now warn on the canonical Windows extended-UNC prefix; the warning can be disabled with --warn=no-windows-extended-unc and also honors the standard warning-as-exception behavior. SCons preserves these paths as literal paths on POSIX and does not normalize Windows extended-UNC semantics. Focused install and lookup tests covering this behavior pass.

@bdbaddog

Copy link
Copy Markdown
Contributor

Always run the full test suite after making changes. It doesn't take that long.

@Boulea7

Boulea7 commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Ran the full suite on Linux with Python 3.11.2 against the published head: python3 -B runtest.py SCons test testing --time --jobs=8. Of 1309 selected test scripts, 1067 passed, 1 failed, and 241 returned NO_RESULT (about 222 seconds, exit 1).

The only failure was test/TEX/variant_dir_newglossary.py, where makeindex cannot find test.ist and test.nto. Running that single test alone on the unchanged master snapshot (0435d19), same machine/interpreter/environment, also reproduces the same failure with exit 1; its root cause is not established. The 241 NO_RESULT results are not counted as passes; their causes have not been classified.

@bdbaddog

Copy link
Copy Markdown
Contributor

@Boulea7 Are you currently using UNC on any platform other than windows?

@mwichmann

Copy link
Copy Markdown
Collaborator

Ran the full suite on Linux with Python 3.11.2 against the published head: python3 -B runtest.py SCons test testing --time --jobs=8. Of 1309 selected test scripts, 1067 passed, 1 failed, and 241 returned NO_RESULT (about 222 seconds, exit 1).

The only failure was test/TEX/variant_dir_newglossary.py, where makeindex cannot find test.ist and test.nto. Running that single test alone on the unchanged master snapshot (0435d19), same machine/interpreter/environment, also reproduces the same failure with exit 1; its root cause is not established. The 241 NO_RESULT results are not counted as passes; their causes have not been classified.

Don't worry about that test, it's a known issue for certain generations of TeX tools (like: current ones).

bdbaddog and others added 2 commits October 17, 2026 17:18
Drop the default-on WindowsExtendedUncWarning for \\?\UNC\ prefixes on
non-Windows hosts. The prefix is a legal POSIX filename, the warning was
inconsistent with other UNC spellings, and it fired on every find_file
call. The UNC lookup and relative-path fixes are unchanged.

Also removes the machine-specific test that depended on
//Users/bdbaddog/.bashrc existing, and a duplicated assertion in
test_rel_path_unc_crossroot.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Replace the //Users/bdbaddog paths in the POSIX install tests with
//scons-sandbox-root. The system test wrote to a real path under the
developer's home directory, so a sandboxing regression could write
outside the sandbox. Drop the .bashrc case from the system test; the
unit tests already cover that mapping.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
@bdbaddog

bdbaddog commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

I've got a commit which removes all the non-windows platform logic.
I think it's only going to cause issues, and generally isn't necessary.
Also using my actual username and home path can cause real issues testing on my machine, so it'll be replaced.

Cleaned up the test to remove any duplication with other system tests and unit test coverage.

Pushing.

Boulea7 and others added 2 commits October 19, 2026 00:07
Disable disk checks while the three simulated UNC tests construct
fictitious server/share nodes. Restore the original checker in the
existing finally blocks so later tests keep their normal behavior.

Assisted-by: OpenAI Codex
Signed-off-by: boulea7 <zln1905391059@163.com>
@bdbaddog
bdbaddog merged commit 3a0084e into SCons:master Oct 18, 2026
10 of 12 checks passed
@mwichmann mwichmann added this to the NextRelease milestone Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants