microsoft/aspire · error · DistributedApplicationException

Aspire.Hosting.Rust requires Cargo 1.71 or later because…

Error message

Aspire.Hosting.Rust requires Cargo 1.71 or later because this 'cargo metadata' output does not include 'workspace_default_members'. Update the Rust toolchain and try again.

What it means

CargoMetadata.Parse reads the JSON output of 'cargo metadata' and requires the 'workspace_default_members' property (an array) to build the workspace model. If that property is missing or not an array, it throws DistributedApplicationException explaining that Cargo 1.71+ is required, since older cargo versions do not emit this field.

Solutions

  1. Update the Rust toolchain: run 'rustup update stable' (or install 1.71+ via rustup) and verify with 'cargo --version'.
  2. In CI, bump the Rust toolchain action/image to 1.71 or later.
  3. Ensure the 'cargo' found on PATH is the rustup-managed one, not a distro package that is too old.
  4. If output was intercepted by a wrapper, run 'cargo metadata --format-version 1' manually and compare against expected schema.

Example fix

// shell
// before
$ cargo --version
 cargo 1.65.0

// after
$ rustup update stable
$ cargo --version
 cargo 1.82.0
Defensive patterns

Strategy: validation

Validate before calling

// Verify the toolchain before starting the apphost:
$ cargo --version   # must be >= 1.71
// or programmatically: parse 'cargo --version' output and compare minor version

Try / catch

try { /* start Rust resource */ }
catch (DistributedApplicationException ex) when (ex.Message.Contains("workspace_default_members"))
{ /* instruct user to upgrade cargo */ }

Prevention

When it happens

Trigger: Running Aspire.Hosting.Rust apphost startup where 'cargo metadata --format-version 1' output JSON lacks 'workspace_default_members' or has it as a non-array value — i.e. cargo older than 1.71 or unexpected output shape.

Common situations: Developers with an old Rust/cargo toolchain (pre-1.71) on PATH; CI images pinned to outdated Rust versions; a wrapper or shim emitting modified cargo metadata; corrupted or partial cargo output.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at src/Aspire.Hosting.Rust/CargoMetadata.cs:91

    /// </remarks>
    public static CargoMetadata Parse(string json)
    {
        using var document = JsonDocument.Parse(json);
        var root = document.RootElement;

        var packages = new List<CargoPackage>();
        if (root.TryGetProperty("packages", out var packagesElement) && packagesElement.ValueKind == JsonValueKind.Array)
        {
            foreach (var packageElement in packagesElement.EnumerateArray())
            {
                packages.Add(ParsePackage(packageElement));
            }
        }

        if (!root.TryGetProperty("workspace_default_members", out var defaultMembersElement)
            || defaultMembersElement.ValueKind != JsonValueKind.Array)
        {
            throw new DistributedApplicationException(
                "Aspire.Hosting.Rust requires Cargo 1.71 or later because this 'cargo metadata' output does not " +
                "include 'workspace_default_members'. Update the Rust toolchain and try again.");
        }

        return new CargoMetadata
        {
            Packages = packages,
            DefaultMemberIds = ReadStringArray(defaultMembersElement),
            TargetDirectory = root.TryGetProperty("target_directory", out var targetDirectoryElement)
                ? targetDirectoryElement.GetString() ?? string.Empty
                : string.Empty
        };
    }

    private static CargoPackage ParsePackage(JsonElement element)
    {
        var binTargets = new List<string>();
        if (element.TryGetProperty("targets", out var targetsElement) && targetsElement.ValueKind == JsonValueKind.Array)

View on GitHub (pinned to 25830f84bd)