{"id":"0007bc9647e7f3ce","repo":"rust-lang/cargo","slug":"manifest-path-does-not-exist","errorCode":null,"errorMessage":"manifest path `{}` does not exist","messagePattern":"manifest path `(.+?)` does not exist","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/util/command_prelude.rs","lineNumber":1056,"sourceCode":"    }\n}\n\npub fn values(args: &ArgMatches, name: &str) -> Vec<String> {\n    args._values_of(name)\n}\n\npub fn values_os(args: &ArgMatches, name: &str) -> Vec<OsString> {\n    args._values_of_os(name)\n}\n\npub fn root_manifest(manifest_path: Option<&Path>, gctx: &GlobalContext) -> CargoResult<PathBuf> {\n    if let Some(manifest_path) = manifest_path {\n        let path = gctx.cwd().join(manifest_path);\n        // In general, we try to avoid normalizing paths in Cargo,\n        // but in this particular case we need it to fix #3586.\n        let path = paths::normalize_path(&path);\n        if !path.exists() {\n            anyhow::bail!(\"manifest path `{}` does not exist\", manifest_path.display())\n        } 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 {","sourceCodeStart":1038,"sourceCodeEnd":1074,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/util/command_prelude.rs#L1038-L1074","documentation":"root_manifest joins the `--manifest-path` argument to the cwd and normalizes it; if the resulting path does not exist on disk, Cargo bails. This is the first existence check before the directory/file checks.","triggerScenarios":"Running any cargo command with `--manifest-path <nonexistent>`, e.g. `cargo build --manifest-path /nope/Cargo.toml` where the file is absent; a typo in the path; a relative path resolved against an unexpected cwd.","commonSituations":"Typos in `--manifest-path`; running cargo from the wrong working directory so a relative path does not resolve; CI checking out into a different directory than the script assumes; leftover path from a moved/deleted project.","solutions":["Verify the path exists: `ls <path>` and correct typos.","Use an absolute path to avoid cwd ambiguity.","If you meant the workspace root, omit `--manifest-path` and let Cargo walk up to find Cargo.toml.","In CI, print `pwd` and `find . -name Cargo.toml` to confirm location."],"exampleFix":"# before\ncargo build --manifest-path Cargo.tml\n\n# after\ncargo build --manifest-path Cargo.toml\n# or simply\ncargo build","handlingStrategy":"validation","validationCode":"use std::path::Path;\nfn ensure_manifest_exists(p: &Path) -> Result<(), anyhow::Error> {\n    if !p.exists() {\n        anyhow::bail!(\"manifest path `{}` does not exist; check the path/cwd\", p.display());\n    }\n    Ok(())\n}\n// call before cargo::ops::* that takes a manifest path","typeGuard":"fn manifest_exists(p: &std::path::Path) -> bool { p.exists() && p.is_file() }","tryCatchPattern":"match root_manifest(Some(path), gctx) {\n    Err(e) if e.to_string().contains(\"does not exist\") => {\n        eprintln!(\"--manifest-path file not found; verify cwd/typos\");\n        return Err(e);\n    }\n    r => r,\n}","preventionTips":["Use absolute paths for `--manifest-path` in CI.","Run `ls`/`test -f` on the path before invoking cargo.","Omit `--manifest-path` when already in the project root."],"tags":["cli","manifest","filesystem","path"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}