{"record":{"id":"9294544cd66cce13","repo":"microsoft/aspire","slug":"the-rust-app-resource-name-targets-target-but-the-default-929454","errorCode":null,"errorMessage":"The Rust app '{resource.Name}' targets '{target}', but the default Rust runtime image is not compatible with its target ABI. Configure runtimeImage with WithDockerfileBaseImage before publishing.","messagePattern":"The Rust app '(.+?)' targets '(.+?)', but the default Rust runtime image is not compatible with its target ABI\\. Configure runtimeImage with WithDockerfileBaseImage before publishing\\.","errorType":"exception","errorClass":"DistributedApplicationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Rust/RustHostingExtensions.cs","lineNumber":921,"sourceCode":"            && (!customBuildImageConfigured || !customRuntimeImageConfigured))\n        {\n            throw new DistributedApplicationException(\n                $\"The Rust app '{resource.Name}' targets '{target}', which is not compatible with the default \" +\n                \"musl build and runtime images. Configure both images in a single \" +\n                \"WithDockerfileBaseImage(buildImage: ..., runtimeImage: ...) call before publishing; later calls replace \" +\n                \"the previous configuration.\");\n        }\n\n        if (!defaultBuildImageCompatible && !customBuildImageConfigured)\n        {\n            throw new DistributedApplicationException(\n                $\"The Rust app '{resource.Name}' targets '{target}', but the default Rust build image does not support \" +\n                $\"container target platform '{platform}'. Configure buildImage with WithDockerfileBaseImage before publishing.\");\n        }\n\n        if (!defaultRuntimeImageCompatible && !customRuntimeImageConfigured)\n        {\n            throw new DistributedApplicationException(\n                $\"The Rust app '{resource.Name}' targets '{target}', but the default Rust runtime image is not compatible \" +\n                \"with its target ABI. Configure runtimeImage with WithDockerfileBaseImage before publishing.\");\n        }\n\n        return platform;\n    }\n\n    private static DistributedApplicationException CreateUnsupportedContainerTargetException(\n        RustAppResource resource,\n        string target)\n        => new(\n            $\"The Rust app '{resource.Name}' targets '{target}', which cannot be mapped to a supported Docker Linux \" +\n            \"container platform. Generated Rust containers support native Linux x86_64, aarch64, 32-bit ARM, \" +\n            \"and 32-bit x86 targets. Use an authored Dockerfile to publish this target.\");\n\n    private sealed class RustPublishState\n    {\n        public ContainerTargetPlatform? TargetPlatform { get; set; }","sourceCodeStart":903,"sourceCodeEnd":939,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Rust/RustHostingExtensions.cs#L903-L939","documentation":"After mapping the cargo target to a container platform, the Rust integration verifies that the default musl runtime image supports the target's ABI (target environment). For Docker's linux/arm platform the default Alpine runtime image only supports musleabi/musleabihf environments, and for other platforms only the plain musl environment. If the target's ABI is not compatible and no custom runtime image was configured via WithDockerfileBaseImage, the library throws when the Dockerfile is finalized for publishing.","triggerScenarios":"Publishing a Rust app whose cargo target ABI mismatches the default runtime image: e.g. WithCargoOptions(o => o.WithTarget(\"x86_64-unknown-linux-gnu\")) (gnu, not musl) or a target environment the Alpine runtime image does not cover, while WithDockerfileBaseImage was never called with a non-null runtimeImage. ResolveContainerTargetPlatform sets defaultRuntimeImageCompatible=false and customRuntimeImageConfigured=false.","commonSituations":"Using a gnu instead of musl target triple and relying on the generated Dockerfile; picking an unusual ARM ABI (musleabi vs musl) for an embedded board; copying a sample config that sets only buildImage via WithDockerfileBaseImage and not runtimeImage.","solutions":["Supply a runtime image matching the target ABI: call WithDockerfileBaseImage(runtimeImage: \"<image for the target ABI>\") before publishing.","Configure both images in one WithDockerfileBaseImage(buildImage: ..., runtimeImage: ...) call when both defaults are incompatible — later calls replace the earlier configuration.","Change the cargo target to a musl environment (e.g. x86_64-unknown-linux-musl, aarch64-unknown-linux-musl, or for linux/arm use *-musleabi/musleabihf) so the default Alpine runtime image is compatible.","Provide your own Dockerfile for ABIs the generated Dockerfile cannot support."],"exampleFix":"// before\nbuilder.AddRustApp(\"worker\", \"../worker\")\n    .WithCargoOptions(o => o.WithTarget(\"aarch64-unknown-linux-gnu\"));\n\n// after\nbuilder.AddRustApp(\"worker\", \"../worker\")\n    .WithCargoOptions(o => o.WithTarget(\"aarch64-unknown-linux-musl\")); // musl ABI matches default runtime image\n// or keep gnu and set a matching runtime image:\n//     .WithDockerfileBaseImage(runtimeImage: \"ubuntu:24.04\");","handlingStrategy":"validation","validationCode":"// Before publishing, check the target ABI against the default runtime image rules\nvar target = \"aarch64-unknown-linux-gnu\"; // your WithCargoOptions target\nvar env = target.Split('-')[^1];\nvar runtimeOk = env == \"musl\" || env is \"musleabi\" or \"musleabihf\";\nif (!runtimeOk)\n{\n    // configure WithDockerfileBaseImage(runtimeImage: ...) before publishing\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    // app host publish/run\n}\ncatch (DistributedApplicationException ex) when (ex.Message.Contains(\"runtime image is not compatible\"))\n{\n    // surface guidance: configure WithDockerfileBaseImage(runtimeImage: ...) matching the target ABI\n}","preventionTips":["Prefer musl target triples when using the generated Dockerfile; gnu ABIs need a custom runtime image.","For linux/arm targets, verify the exact ABI (musleabi/musleabihf) your runtime image supports.","Set both buildImage and runtimeImage together in one WithDockerfileBaseImage call when leaving the supported matrix.","Run the publish pipeline in CI whenever target triples change."],"tags":["rust","docker","publishing","cross-compilation","abi"],"backgroundTag":"unsupported-platform","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"}