{"record":{"id":"27a7ba5ca6628da4","repo":"microsoft/aspire","slug":"the-rust-app-resourcename-builds-from-the-absolute-path","errorCode":null,"errorMessage":"The Rust app '{resourceName}' builds from the absolute path '{manifestPath}'. Publishing needs a path relative to its app directory '{workingDirectory}'.","messagePattern":"The Rust app '(.+?)' builds from the absolute path '(.+?)'\\. Publishing needs a path relative to its app directory '(.+?)'\\.","errorType":"exception","errorClass":"DistributedApplicationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Rust/RustDockerfileGenerator.cs","lineNumber":212,"sourceCode":"            if (cargoArgs[i] == \"--manifest-path\" && cargoArgs[i + 1] == manifestPath)\n            {\n                cargoArgs[i + 1] = containerPath;\n            }\n        }\n    }\n\n    // Only the app directory is copied into the image, so the manifest has to sit inside it. Paths are\n    // required to be relative because an absolute one can spell that same directory differently to us.\n    private static string? ValidateManifestPath(string? manifestPath, string workingDirectory, string resourceName)\n    {\n        if (manifestPath is null)\n        {\n            return null;\n        }\n\n        if (Path.IsPathRooted(manifestPath))\n        {\n            throw new DistributedApplicationException(\n                $\"The Rust app '{resourceName}' builds from the absolute path '{manifestPath}'. Publishing needs a path \" +\n                $\"relative to its app directory '{workingDirectory}'.\");\n        }\n\n        var platformManifestPath = OperatingSystem.IsWindows()\n            ? manifestPath.Replace('\\\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar)\n            : manifestPath;\n\n        var filesystemWorkingDirectory = Path.GetFullPath(workingDirectory);\n        var filesystemManifest = Path.GetFullPath(platformManifestPath, workingDirectory);\n\n        if (!PathNormalizer.TryResolveSymlinks(filesystemWorkingDirectory, out var canonicalWorkingDirectory)\n            || !PathNormalizer.TryResolveSymlinks(filesystemManifest, out var canonicalManifest))\n        {\n            throw new DistributedApplicationException(\n                $\"The Rust app '{resourceName}' builds from '{manifestPath}', but its symbolic links could not be \" +\n                \"fully resolved. Publishing stops rather than accepting a partially canonicalized path.\");\n        }","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Rust/RustDockerfileGenerator.cs#L194-L230","documentation":"ValidateManifestPath in RustDockerfileGenerator throws this DistributedApplicationException during publishing when the Cargo.toml manifest path recorded for the resource is an absolute path. The Dockerfile build context is the app directory, so the COPY/compose logic needs the manifest path expressed relative to that directory; an absolute path cannot be rebased safely, so publishing stops with a clear message instead of emitting a broken Dockerfile.","triggerScenarios":"Publishing (docker/compose generation) a RustAppResource whose resolved manifest path is rooted — e.g. the app directory or manifest was recorded/resolved as an absolute path rather than one relative to workingDirectory.","commonSituations":"Configuring the resource with a fully qualified path (e.g. C:\\src\\app\\Cargo.toml or /home/user/app/Cargo.toml) where a relative path is expected; custom code that computes the manifest path with Path.GetFullPath before handing it to the resource model.","solutions":["Pass a path relative to the app directory when configuring the Rust resource (e.g. \"Cargo.toml\" or \"src/../Cargo.toml\" style relative paths)","Fix any custom path computation that calls Path.GetFullPath / combines with an absolute root before storing the manifest path","Verify the resource's working directory is set correctly so the relative manifest path resolves inside it"],"exampleFix":"// before\nvar manifest = Path.GetFullPath(Path.Combine(appDir, \"Cargo.toml\")); // absolute\nbuilder.AddRustApp(\"app\", manifest);\n// after\nbuilder.AddRustApp(\"app\", \"Cargo.toml\"); // relative to the app directory","handlingStrategy":"validation","validationCode":"if (Path.IsPathRooted(manifestPath)) throw new InvalidOperationException($\"Manifest path '{manifestPath}' must be relative to the app directory.\");","typeGuard":"bool IsRelativeManifestPath(string p) => !Path.IsPathRooted(p);","tryCatchPattern":"try { await PublishAsync(appModel); } catch (DistributedApplicationException ex) when (ex.Message.Contains(\"absolute path\")) { log.LogError(ex, \"Absolute cargo manifest path\"); }","preventionTips":["Always pass paths relative to the app directory for Rust resources","Avoid Path.GetFullPath when computing manifest paths handed to the resource model","Test the publish path (not just run) locally so rooted paths surface before CI"],"tags":["rust","dockerfile","publish","path"],"backgroundTag":"invalid-argument-format","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}