Skip to content

Fix: mesonbuild/msubprojects.py line 723: source_dir =... - #16093

Open
M001N wants to merge 2 commits into
mesonbuild:masterfrom
M001N:oss-engine/d25ec19f-51ea113a
Open

Fix: mesonbuild/msubprojects.py line 723: source_dir =...#16093
M001N wants to merge 2 commits into
mesonbuild:masterfrom
M001N:oss-engine/d25ec19f-51ea113a

Conversation

@M001N

@M001N M001N commented Aug 10, 2026

Copy link
Copy Markdown

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

[!INFO]
🤖 This PR was prepared with AI assistance (Claude, via an autonomous engineering workflow with human review and approval gates). The fix was independently reviewed and manually verified by a human before submission.

Comment thread check_relpath_fix.py Outdated
@@ -0,0 +1,59 @@
#!/usr/bin/env python3

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants