{"record":{"id":"bc9ed9216e9bc163","repo":"rust-lang/cargo","slug":"the-manifest-path-must-be-a-path-to-a-cargo-toml-f","errorCode":null,"errorMessage":"the manifest-path must be a path to a Cargo.toml file: `{}`","messagePattern":"the manifest-path must be a path to a Cargo\\.toml file: `(.+?)`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/util/command_prelude.rs","lineNumber":1075,"sourceCode":"        } else if path.is_dir() {\n            let child_path = path.join(\"Cargo.toml\");\n            let suggested_path = if child_path.exists() {\n                format!(\"\\nhelp: {} exists\", child_path.display())\n            } else {\n                \"\".to_string()\n            };\n            anyhow::bail!(\n                \"manifest path `{}` is a directory but expected a file{suggested_path}\",\n                manifest_path.display()\n            )\n        } else if !path.ends_with(\"Cargo.toml\") && !crate::workspace::parser::is_embedded(&path) {\n            if gctx.cli_unstable().script {\n                anyhow::bail!(\n                    \"the manifest-path must be a path to a Cargo.toml or script file: `{}`\",\n                    path.display()\n                )\n            } else {\n                anyhow::bail!(\n                    \"the manifest-path must be a path to a Cargo.toml file: `{}`\",\n                    path.display()\n                )\n            }\n        }\n        if crate::workspace::parser::is_embedded(&path) && !gctx.cli_unstable().script {\n            anyhow::bail!(\"embedded manifest `{}` requires `-Zscript`\", path.display())\n        }\n        Ok(path)\n    } else {\n        find_root_manifest_for_wd(gctx.cwd())\n    }\n}\n\npub fn get_registry_candidates() -> CargoResult<Vec<clap_complete::CompletionCandidate>> {\n    let gctx = new_gctx_for_completions()?;\n\n    if let Ok(Some(registries)) =","sourceCodeStart":1057,"sourceCodeEnd":1093,"githubUrl":"https://github.com/rust-lang/cargo/blob/98a09e7e7d62850f14e5b6132101fc1edd19a16f/src/util/command_prelude.rs#L1057-L1093","documentation":"Without -Zscript, root_manifest() requires --manifest-path to end in Cargo.toml (or be an embedded manifest, which itself needs -Zscript). Any other file extension is rejected on stable Cargo.","triggerScenarios":"Stable Cargo invoked with `--manifest-path README.md` or any non-Cargo.toml file.","commonSituations":"Typo in the path; pointing at a generated/template file that is not a real manifest.","solutions":["Point --manifest-path at a valid Cargo.toml.","If you intend a single-file script, switch to nightly and pass -Zscript (and rename the file appropriately)."],"exampleFix":"# before\n# cargo build --manifest-path ./project.toml\n\n# after\n# cargo build --manifest-path ./Cargo.toml","handlingStrategy":"validation","validationCode":"use std::path::Path;\n\nfn validate_stable_manifest(p: &Path) -> Result<(), String> {\n    if p.ends_with(\"Cargo.toml\") { return Ok(()); }\n    Err(format!(\"on stable cargo, --manifest-path must point to a Cargo.toml: {p:?}\"))\n}","typeGuard":"fn is_cargo_toml(p: &std::path::Path) -> bool {\n    p.ends_with(\"Cargo.toml\")\n}","tryCatchPattern":null,"preventionTips":["On stable cargo, always point --manifest-path at a Cargo.toml file.","Reserve single-file scripts for nightly + -Zscript."],"tags":["manifest","paths","cli"],"backgroundTag":null,"analyzedSha":"98a09e7e7d62850f14e5b6132101fc1edd19a16f","analyzedAt":"2026-08-11T17:42:36.556Z","contentChangedAt":"2026-08-11T17:42:36.556Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}