{"record":{"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":null,"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/98a09e7e7d62850f14e5b6132101fc1edd19a16f/src/util/command_prelude.rs#L1038-L1074","documentation":"root_manifest() resolves --manifest-path: it joins cwd + the path, normalizes it, and checks existence. If the normalized path does not exist on disk, this bail fires with the user-supplied path verbatim.","triggerScenarios":"Any subcommand invoked with --manifest-path pointing at a non-existent file or directory (e.g. `cargo build --manifest-path missing/Cargo.toml`).","commonSituations":"Wrong relative path because cwd differs from expectation (common in CI); typo in path; manifest generated by a build step that did not run.","solutions":["Verify the path exists: `ls -l <manifest-path>` from the cwd Cargo will use.","Use an absolute path for --manifest-path in CI.","Confirm the working directory Cargo runs from (it is the resolved cwd, not necessarily the script's dir)."],"exampleFix":"# before\n# cargo build --manifest-path ./Cargo.toml   # run from wrong dir\n\n# after\n# cargo build --manifest-path /abs/path/to/Cargo.toml","handlingStrategy":"validation","validationCode":"use std::path::Path;\n\nfn ensure_manifest_exists(p: &Path) -> Result<PathBuf, String> {\n    let p = paths::normalize_path(p);\n    if !p.exists() {\n        return Err(format!(\"manifest path `{}` does not exist\", p.display()));\n    }\n    Ok(p)\n}\n\n// let p = ensure_manifest_exists(&gctx.cwd().join(manifest))?;","typeGuard":"fn manifest_path_is_file(p: &std::path::Path) -> bool {\n    p.exists() && p.is_file()\n}","tryCatchPattern":"match root_manifest(manifest_path, gctx) {\n    Ok(p) => { /* use p */ }\n    Err(e) if e.to_string().contains(\"does not exist\") => {\n        eprintln!(\"--manifest-path missing; check cwd={} and the path\", gctx.cwd().display());\n        return Err(e);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Use absolute paths for --manifest-path in CI scripts.","Echo the resolved cwd before invoking cargo to debug path issues.","Add a pre-flight `test -f <path>` check in build scripts."],"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"}