Repository navigation
Fix UNC lookup and relative path handling - #4914
Conversation
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
|
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). |
Assisted-by: OpenAI Codex Signed-off-by: boulea7 <zln1905391059@163.com>
|
I'm fairly certain we should only be handling UNC paths on windows computers. 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>
|
Removed the cross-platform UNC branch and restored native |
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: |
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>
|
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. |
|
Always run the full test suite after making changes. It doesn't take that long. |
|
Ran the full suite on Linux with Python 3.11.2 against the published head: The only failure was |
|
@Boulea7 Are you currently using UNC on any platform other than windows? |
Don't worry about that test, it's a known issue for certain generations of TeX tools (like: current ones). |
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>
|
I've got a commit which removes all the non-windows platform logic. Cleaned up the test to remove any duplication with other system tests and unit test coverage. Pushing. |
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>
Summary
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=8selected 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: