Fix: mesonbuild/msubprojects.py line 723: source_dir =... - #16093
Open
M001N wants to merge 2 commits into
Open
Conversation
bonzini
reviewed
Aug 10, 2026
| @@ -0,0 +1,59 @@ | |||
| #!/usr/bin/env python3 | |||
Contributor
There was a problem hiding this comment.
this is not how you do testcases.
Replace the standalone check_relpath_fix.py script (rejected by maintainer review as not the project's testing convention) with a test method in unittests/machinefiletests.py, following the existing TestCase style in that file. The test monkeypatches os.path.relpath to raise ValueError, simulating the Windows cross-mount/UNC scenario, and verifies msubprojects.run() handles it gracefully instead of crashing.
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
Wrapped the os.path.relpath(...) call in try/except ValueError, falling back to the already-computed realpath (absolute path) when relpath raises due to a cross-mount/UNC situation.
Problem
mesonbuild/meson issue reference: #13814 - Meson throws exception updating subprojects
Root Cause
mesonbuild/msubprojects.py line 723: source_dir = os.path.relpath(os.path.realpath(options.sourcedir)) calls relpath with no start=, defaulting to os.getcwd(). On Windows, ntpath.relpath raises ValueError when the two paths are on different drives/UNC mounts, and this was unhandled, surfacing as an internal Meson exception instead of a graceful error.
Testing
PASS - exit 0 with fix applied; empirically verified exit 1 (uncaught ValueError) on unfixed code via git stash before committing.
Related Issue
#13814 - Meson throws exception updating subprojects