{"record":{"id":"13e2fbc4394641d5","repo":"stride3d/stride","slug":"file-filepath-must-exist","errorCode":null,"errorMessage":"File [{filePath}] must exist","messagePattern":"File \\[(.+?)\\] must exist","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/assets/Stride.Core.Assets/PackageSession.cs","lineNumber":847,"sourceCode":"    /// Loads a package from specified file path.\n    /// </summary>\n    /// <param name=\"filePath\">The file path to a package file.</param>\n    /// <param name=\"sessionResult\">The session result.</param>\n    /// <param name=\"loadParameters\">The load parameters.</param>\n    /// <exception cref=\"ArgumentNullException\">filePath</exception>\n    /// <exception cref=\"ArgumentException\">File [{0}] must exist.ToFormat(filePath);filePath</exception>\n    public static void Load(string filePath, PackageSessionResult sessionResult, PackageLoadParameters? loadParameters = null)\n    {\n        ArgumentNullException.ThrowIfNull(filePath);\n        ArgumentNullException.ThrowIfNull(sessionResult);\n\n        // Make sure with have valid parameters\n        loadParameters ??= PackageLoadParameters.Default();\n\n        // Make sure to use a full path.\n        filePath = FileUtility.GetAbsolutePath(filePath);\n\n        if (!File.Exists(filePath)) throw new ArgumentException($\"File [{filePath}] must exist\", nameof(filePath));\n\n        try\n        {\n            // Enable reference analysis caching during loading\n            AssetReferenceAnalysis.EnableCaching = true;\n\n            using var profile = Profiler.Begin(PackageSessionProfilingKeys.Loading);\n            sessionResult.Clear();\n            sessionResult.Progress(\"Loading..\", 0, 1);\n\n            var session = new PackageSession();\n\n            var cancelToken = loadParameters.CancelToken;\n            SolutionProject? firstProject = null;\n\n            // If we have a solution, load all packages\n            if (Solution.IsSolutionFile(filePath))\n            {","sourceCodeStart":829,"sourceCodeEnd":865,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/assets/Stride.Core.Assets/PackageSession.cs#L829-L865","documentation":"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.","triggerScenarios":"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.","commonSituations":"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 ~.","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."],"exampleFix":"// before\nvar session = PackageSession.Load(\"MyGame.sdpkg\");\n// after\nvar absPath = Path.GetFullPath(Path.Combine(appBaseDir, \"MyGame.sdpkg\"));\nif (!File.Exists(absPath))\n    throw new FileNotFoundException($\"Package file not found: {absPath}\", absPath);\nvar session = PackageSession.Load(absPath);","handlingStrategy":"validation","validationCode":"var absPath = Path.GetFullPath(filePath);\nif (!File.Exists(absPath))\n    throw new FileNotFoundException($\"Package file not found: {absPath}\", absPath);\nvar session = PackageSession.Load(absPath);","typeGuard":"static bool IsValidPackagePath(string path) =>\n    !string.IsNullOrWhiteSpace(path) && File.Exists(Path.GetFullPath(path));","tryCatchPattern":"try { session = PackageSession.Load(filePath); }\ncatch (ArgumentException ex) when (ex.Message.StartsWith(\"File [\"))\n{\n    logger.LogError(ex, \"Package file missing: {FilePath}\", filePath);\n}","preventionTips":["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."],"tags":["file-io","argument-validation","packages"],"backgroundTag":"file-not-found","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}