stride3d/stride · error · InvalidOperationException
Path should have no drive information/or both drive…
Error message
Path should have no drive information/or both drive information simultaneously
What it means
UPath.MakeRelative throws InvalidOperationException when the path and its anchorDirectory disagree about drive information — one has a drive letter/URI scheme and the other does not. Paths with mixed drive-ness cannot be meaningfully related. This is a cross-domain consistency check after the absoluteness check.
Solutions
- Normalize both paths to the same drive/scheme domain before calling MakeRelative
- Strip or add drive information consistently (e.g. use the mounted root path without drive)
- Use the same path provider (VFS vs raw filesystem) for both paths
Example fix
// before
var rel = new UFile("C:/data/model.xk").MakeRelative(new UDirectory("/data")); // drive mismatch
// after
var rel = new UFile("/data/model.xk").MakeRelative(new UDirectory("/data")); Defensive patterns
Strategy: validation
Validate before calling
if (path.HasDrive != anchorDirectory.HasDrive)
throw new InvalidOperationException("Path and anchor must agree on drive information.");
var rel = path.MakeRelative(anchorDirectory); Prevention
- Use one path domain (VFS-style or drive-qualified) consistently across the codebase
- Normalize paths to a common form before path algebra
When it happens
Trigger: Calling MakeRelative where e.g. this = "/assets/x" (no drive) and anchor = "C:/assets" (has drive), or vice versa; also mixing scheme-less and scheme'd database paths.
Common situations: Combining paths from different sources (absolute Windows paths vs. virtual/mount-relative Stride paths), switching between file system paths and Stride's virtual file system URLs.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- A file path cannot end with with directory char '\' or '/'…
- Expecting an absolute directory
- Operation 'Read' is not supported
- Operation 'Write' is not supported
- The provided path is not a valid path name.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/c9346c5136b1685c.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Design/IO/UPath.cs:365
#else
if (anchorDirectory is null) throw new ArgumentNullException(nameof(anchorDirectory));
#endif
// If the toRelativize path is already relative, don't bother
if (IsRelative)
{
return this;
}
// If anchor directory is not absolute directory, throw an error
if (!anchorDirectory.IsAbsolute)
{
throw new ArgumentException("Expecting an absolute directory", nameof(anchorDirectory));
}
if (anchorDirectory.HasDrive != HasDrive)
{
throw new InvalidOperationException("Path should have no drive information/or both drive information simultaneously");
}
// Return a "." when the directory is the same
if (this is UDirectory && anchorDirectory == this)
{
return UDirectory.This;
}
// Get the full path of the anchor directory
var anchorPath = anchorDirectory.FullPath;
// Builds an absolute path for the toRelative path (directory-only)
var absoluteFile = Combine(anchorDirectory, this);
var absolutePath = absoluteFile.GetFullDirectory().FullPath;
var relativePath = new StringBuilder();
var index = anchorPath.Length;View on GitHub (pinned to 96fad776d2)