{"record":{"id":"41de9c1cb65ad550","repo":"microsoft/aspire","slug":"bundle-version-directory-fullversiondirectory-does-not-exist","errorCode":null,"errorMessage":"Bundle version directory '{fullVersionDirectory}' does not exist.","messagePattern":"Bundle version directory '(.+?)' does not exist\\.","errorType":"exception","errorClass":"DirectoryNotFoundException","httpStatus":null,"severity":"error","filePath":"src/Shared/BundleVersionLease.cs","lineNumber":101,"sourceCode":"    public string? CommandName { get; }\n\n    /// <summary>\n    /// Gets when the lease was acquired.\n    /// </summary>\n    public DateTimeOffset AcquiredUtc { get; }\n\n    /// <summary>\n    /// Creates a lease for <paramref name=\"versionDirectory\"/>.\n    /// </summary>\n    public static BundleVersionLease Acquire(string versionDirectory, string holderKind, string? commandName = null)\n    {\n        ArgumentException.ThrowIfNullOrWhiteSpace(versionDirectory);\n        ArgumentException.ThrowIfNullOrWhiteSpace(holderKind);\n\n        var fullVersionDirectory = Path.GetFullPath(versionDirectory);\n        if (!Directory.Exists(fullVersionDirectory))\n        {\n            throw new DirectoryNotFoundException($\"Bundle version directory '{fullVersionDirectory}' does not exist.\");\n        }\n\n        var leasesDirectory = Path.Combine(fullVersionDirectory, LeasesDirectoryName);\n        Directory.CreateDirectory(leasesDirectory);\n\n        var heldLease = HeldFileLease.Acquire(leasesDirectory, CreateLeaseFileNamePrefix(), LeaseExtension);\n\n        try\n        {\n            var versionId = Path.GetFileName(fullVersionDirectory.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar));\n            var lease = new BundleVersionLease(\n                versionId,\n                fullVersionDirectory,\n                heldLease.LeasePath,\n                Environment.ProcessId,\n                GetCurrentProcessStartTimeTicks(),\n                holderKind,\n                commandName,","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Shared/BundleVersionLease.cs#L83-L119","documentation":"BundleVersionLease.Acquire coordinates exclusive access to a bundle version directory via file leases. Before acquiring, it validates that the version directory exists on disk; if not it throws DirectoryNotFoundException with the fully resolved path, preventing lease files from being created in a nonexistent location.","triggerScenarios":"Calling Acquire (directly or via TryAcquireFromEnvironment when the env var points at a path) with a versionDirectory that was deleted, never created, or mounted after the call.","commonSituations":"Stale environment variable pointing at a cleaned temp directory; bundle upgraded/removed by another process between validation and acquisition; wrong path passed on the CLI.","solutions":["Ensure the version directory exists before acquiring: Directory.CreateDirectory(versionDirectory)","Re-check where the path in the environment variable came from; recreate the bundle version","Re-run the bundle installation so the version directory is created","Verify the path is not relative to an unexpected working directory — pass an absolute path"],"exampleFix":"// before\nBundleVersionLease.Acquire(versionDir, holderKind: \"cli\");\n// after\nDirectory.CreateDirectory(versionDir);\nBundleVersionLease.Acquire(versionDir, holderKind: \"cli\");","handlingStrategy":"try-catch","validationCode":"var full = Path.GetFullPath(versionDirectory);\nif (!Directory.Exists(full)) Directory.CreateDirectory(full);","typeGuard":null,"tryCatchPattern":"try { lease = BundleVersionLease.Acquire(versionDir, holderKind); }\ncatch (DirectoryNotFoundException)\n{ /* recreate the version directory and retry once */ }","preventionTips":["Create the version directory as part of bundle installation, before leasing","Pass absolute paths; don't rely on the current working directory","Clean up env-var pointers when temp directories are purged"],"tags":["directory","filesystem","lease"],"backgroundTag":"directory-not-found","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}