stride3d/stride · error · ArgumentException
File [ ] must exist
Error message
File [{filePath}] must exist What it means
Thrown by PackageSession.Load when the package file path passed in does not exist on disk after being resolved to an absolute path. The library validates parameters up front so it fails fast instead of surfacing a confusing file-read error deep inside the load pipeline.
Solutions
- Verify the file exists at the exact path before calling Load (File.Exists on the absolute path).
- Resolve relative paths against the intended base directory (Path.GetFullPath) instead of relying on the current working directory.
- Check the path for typos, wrong drive, and unexpanded variables (%VAR%, ~/).
- Restore or re-clone the missing package file from version control.
- Wrap the Load call in a try/catch on ArgumentException to surface a user-friendly message.
Example fix
// before
var session = PackageSession.Load("MyGame.sdpkg");
// after
var absPath = Path.GetFullPath(Path.Combine(appBaseDir, "MyGame.sdpkg"));
if (!File.Exists(absPath))
throw new FileNotFoundException($"Package file not found: {absPath}", absPath);
var session = PackageSession.Load(absPath); Defensive patterns
Strategy: validation
Validate before calling
var absPath = Path.GetFullPath(filePath);
if (!File.Exists(absPath))
throw new FileNotFoundException($"Package file not found: {absPath}", absPath);
var session = PackageSession.Load(absPath); Type guard
static bool IsValidPackagePath(string path) =>
!string.IsNullOrWhiteSpace(path) && File.Exists(Path.GetFullPath(path)); Try / catch
try { session = PackageSession.Load(filePath); }
catch (ArgumentException ex) when (ex.Message.StartsWith("File ["))
{
logger.LogError(ex, "Package file missing: {FilePath}", filePath);
} Prevention
- Always pass absolute, verified paths to Load.
- Check File.Exists right before the call in case of races.
- Avoid relying on the process working directory; resolve against a known base dir.
- Log the resolved absolute path when load fails.
When it happens
Trigger: Calling PackageSession.Load(filePath) with a path that is missing, deleted, or only exists relative to a different working directory than the one at call time.
Common situations: Hard-coding a relative path while the app runs from another working directory; the asset was moved or deleted; case-sensitivity mismatches on Linux; using a path with unexpanded environment variables or ~.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Package must be added to an existing PackageSession
- The target version is lower or equal to the start version.
- The upgrader has a target version higher that the current…
- The relativePath argument is null or empty
- Type [ ] must be assignable to Asset
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/13e2fbc4394641d5.
Report an issue: GitHub.
Appendix: source
Thrown at sources/assets/Stride.Core.Assets/PackageSession.cs:847
/// Loads a package from specified file path.
/// </summary>
/// <param name="filePath">The file path to a package file.</param>
/// <param name="sessionResult">The session result.</param>
/// <param name="loadParameters">The load parameters.</param>
/// <exception cref="ArgumentNullException">filePath</exception>
/// <exception cref="ArgumentException">File [{0}] must exist.ToFormat(filePath);filePath</exception>
public static void Load(string filePath, PackageSessionResult sessionResult, PackageLoadParameters? loadParameters = null)
{
ArgumentNullException.ThrowIfNull(filePath);
ArgumentNullException.ThrowIfNull(sessionResult);
// Make sure with have valid parameters
loadParameters ??= PackageLoadParameters.Default();
// Make sure to use a full path.
filePath = FileUtility.GetAbsolutePath(filePath);
if (!File.Exists(filePath)) throw new ArgumentException($"File [{filePath}] must exist", nameof(filePath));
try
{
// Enable reference analysis caching during loading
AssetReferenceAnalysis.EnableCaching = true;
using var profile = Profiler.Begin(PackageSessionProfilingKeys.Loading);
sessionResult.Clear();
sessionResult.Progress("Loading..", 0, 1);
var session = new PackageSession();
var cancelToken = loadParameters.CancelToken;
SolutionProject? firstProject = null;
// If we have a solution, load all packages
if (Solution.IsSolutionFile(filePath))
{View on GitHub (pinned to 96fad776d2)