{"record":{"id":"8d4bf9c79f3a8552","repo":"cross-rs/cross","slug":"unable-to-find-dockerfile-for-target-target","errorCode":null,"errorMessage":"unable to find dockerfile for target \"{target}\"","messagePattern":"unable to find dockerfile for target \"(.+?)\"","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xtask/src/build_docker_image.rs","lineNumber":96,"sourceCode":"    #[clap(long, short = 'a', action = clap::builder::ArgAction::Append)]\n    pub platform: Vec<ImagePlatform>,\n    /// Targets to build for\n    #[clap()]\n    pub targets: Vec<ImageTarget>,\n}\n\nfn locate_dockerfile(\n    target: ImageTarget,\n    docker_root: &Path,\n    cross_toolchain_root: &Path,\n) -> cross::Result<(ImageTarget, String)> {\n    let dockerfile_name = format!(\"Dockerfile.{target}\");\n    let dockerfile_root = if cross_toolchain_root.join(&dockerfile_name).exists() {\n        &cross_toolchain_root\n    } else if docker_root.join(&dockerfile_name).exists() {\n        &docker_root\n    } else {\n        eyre::bail!(\"unable to find dockerfile for target \\\"{target}\\\"\");\n    };\n    let dockerfile = dockerfile_root.join(dockerfile_name).to_utf8()?.to_string();\n    Ok((target, dockerfile))\n}\n\npub fn build_docker_image(\n    BuildDockerImage {\n        ref_type,\n        ref_name,\n        build_opts,\n        is_latest,\n        tag: tag_override,\n        repository,\n        labels,\n        dry_run,\n        force,\n        push,\n        no_output,","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/cross-rs/cross/blob/8c1a8aa4b661711f4b7b6ac07c2e8929ce2f7d27/xtask/src/build_docker_image.rs#L78-L114","documentation":"locate_dockerfile resolves the Dockerfile for a cross-compilation target. It looks for `Dockerfile.<target>` first in the cross-toolchain root, then in the docker root; if the file exists in neither location it bails with this error. It is thrown because the target has no corresponding dockerfile checked into either expected directory.","triggerScenarios":"The target name passed to build_docker_image has no `Dockerfile.<target>` file in either `cross_toolchain_root` or `docker_root` (checked via .exists()).","commonSituations":"Adding a new target to the build matrix without creating its Dockerfile.<target>; a typo in the target triple (e.g. 'aarch64-unknow-linux-gnu'); renaming/moving the docker directory so the lookup path is wrong; running the xtask on a partially cloned repo.","solutions":["Create the missing file `Dockerfile.<target>` in docker_root (or cross_toolchain_root)","Verify the target triple spelling matches an existing Dockerfile.<target> filename","Check that cross_toolchain_root/docker_root point at the directories that actually contain the dockerfiles (CI checkout depth/path config)","List files named Dockerfile.* in the repo and pick a target that exists"],"exampleFix":"// before\nxtask build-docker-image --target aarch64-unknow-linux-gnu\n// after\nxtask build-docker-image --target aarch64-unknown-linux-gnu // matches Dockerfile.aarch64-unknown-linux-gnu","handlingStrategy":"validation","validationCode":"use std::path::Path;\nfn dockerfile_exists(cross_root: &Path, docker_root: &Path, target: &str) -> bool {\n    let name = format!(\"Dockerfile.{target}\");\n    cross_root.join(&name).exists() || docker_root.join(&name).exists()\n}\n// check before invoking xtask\nassert!(dockerfile_exists(&cross_root, &docker_root, &target), \"missing Dockerfile for {target}\");","typeGuard":null,"tryCatchPattern":"let out = build_docker_image(target, ...);\nif let Err(e) = out {\n    if e.to_string().contains(\"unable to find dockerfile\") {\n        eprintln!(\"No Dockerfile.{target} in cross_toolchain_root or docker_root; add one or fix the target triple\");\n    } else { return Err(e); }\n}","preventionTips":["Keep one Dockerfile.<target> per target in the build matrix and add it in the same PR that adds the target","Verify target triples against rustc's target list (`rustc --print target-list`)","Include the docker directory in your repo checkout/CI checkout settings","Add a test iterating the target matrix and asserting each Dockerfile exists"],"tags":["docker","build","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"8c1a8aa4b661711f4b7b6ac07c2e8929ce2f7d27","analyzedAt":"2026-09-13T15:10:43.988Z","contentChangedAt":"2026-09-13T15:10:43.988Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}