microsoft/aspire · error · DistributedApplicationException

The Rust app ' ' builds from the absolute path ' '…

Error message

The Rust app '{resourceName}' builds from the absolute path '{manifestPath}'. Publishing needs a path relative to its app directory '{workingDirectory}'.

What it means

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.

Solutions

  1. Pass a path relative to the app directory when configuring the Rust resource (e.g. "Cargo.toml" or "src/../Cargo.toml" style relative paths)
  2. Fix any custom path computation that calls Path.GetFullPath / combines with an absolute root before storing the manifest path
  3. Verify the resource's working directory is set correctly so the relative manifest path resolves inside it

Example fix

// before
var manifest = Path.GetFullPath(Path.Combine(appDir, "Cargo.toml")); // absolute
builder.AddRustApp("app", manifest);
// after
builder.AddRustApp("app", "Cargo.toml"); // relative to the app directory
Defensive patterns

Strategy: validation

Validate before calling

if (Path.IsPathRooted(manifestPath)) throw new InvalidOperationException($"Manifest path '{manifestPath}' must be relative to the app directory.");

Type guard

bool IsRelativeManifestPath(string p) => !Path.IsPathRooted(p);

Try / catch

try { await PublishAsync(appModel); } catch (DistributedApplicationException ex) when (ex.Message.Contains("absolute path")) { log.LogError(ex, "Absolute cargo manifest path"); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/27a7ba5ca6628da4. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Hosting.Rust/RustDockerfileGenerator.cs:212

            if (cargoArgs[i] == "--manifest-path" && cargoArgs[i + 1] == manifestPath)
            {
                cargoArgs[i + 1] = containerPath;
            }
        }
    }

    // Only the app directory is copied into the image, so the manifest has to sit inside it. Paths are
    // required to be relative because an absolute one can spell that same directory differently to us.
    private static string? ValidateManifestPath(string? manifestPath, string workingDirectory, string resourceName)
    {
        if (manifestPath is null)
        {
            return null;
        }

        if (Path.IsPathRooted(manifestPath))
        {
            throw new DistributedApplicationException(
                $"The Rust app '{resourceName}' builds from the absolute path '{manifestPath}'. Publishing needs a path " +
                $"relative to its app directory '{workingDirectory}'.");
        }

        var platformManifestPath = OperatingSystem.IsWindows()
            ? manifestPath.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar)
            : manifestPath;

        var filesystemWorkingDirectory = Path.GetFullPath(workingDirectory);
        var filesystemManifest = Path.GetFullPath(platformManifestPath, workingDirectory);

        if (!PathNormalizer.TryResolveSymlinks(filesystemWorkingDirectory, out var canonicalWorkingDirectory)
            || !PathNormalizer.TryResolveSymlinks(filesystemManifest, out var canonicalManifest))
        {
            throw new DistributedApplicationException(
                $"The Rust app '{resourceName}' builds from '{manifestPath}', but its symbolic links could not be " +
                "fully resolved. Publishing stops rather than accepting a partially canonicalized path.");
        }

View on GitHub (pinned to 25830f84bd)