rust-lang/cargo · error
manifest path ` ` does not exist
Error message
manifest path `{}` does not exist What it means
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.
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).
Example fix
# before # cargo build --manifest-path ./Cargo.toml # run from wrong dir # after # cargo build --manifest-path /abs/path/to/Cargo.toml
Defensive patterns
Strategy: validation
Validate before calling
use std::path::Path;
fn ensure_manifest_exists(p: &Path) -> Result<PathBuf, String> {
let p = paths::normalize_path(p);
if !p.exists() {
return Err(format!("manifest path `{}` does not exist", p.display()));
}
Ok(p)
}
// let p = ensure_manifest_exists(&gctx.cwd().join(manifest))?; Type guard
fn manifest_path_is_file(p: &std::path::Path) -> bool {
p.exists() && p.is_file()
} Try / catch
match root_manifest(manifest_path, gctx) {
Ok(p) => { /* use p */ }
Err(e) if e.to_string().contains("does not exist") => {
eprintln!("--manifest-path missing; check cwd={} and the path", gctx.cwd().display());
return Err(e);
}
Err(e) => return Err(e),
} Prevention
- 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.
When it happens
Trigger: Any subcommand invoked with --manifest-path pointing at a non-existent file or directory (e.g. `cargo build --manifest-path missing/Cargo.toml`).
Common situations: Wrong relative path because cwd differs from expectation (common in CI); typo in path; manifest generated by a build step that did not run.
Related errors
- manifest path ` ` is a directory but expected a file
- the manifest-path must be a path to a Cargo.toml file
- Could not find ` ` in
- could not find ` ` in ` ` or any parent directory, but…
- could not find ` ` in ` ` or any parent directory
AI-assisted analysis of rust-lang/cargo@98a09e7e7d (2026-08-11).
Data as JSON: /api/errors/0007bc9647e7f3ce.
Report an issue: GitHub.
Appendix: source
Thrown at src/util/command_prelude.rs:1056
}
}
pub fn values(args: &ArgMatches, name: &str) -> Vec<String> {
args._values_of(name)
}
pub fn values_os(args: &ArgMatches, name: &str) -> Vec<OsString> {
args._values_of_os(name)
}
pub fn root_manifest(manifest_path: Option<&Path>, gctx: &GlobalContext) -> CargoResult<PathBuf> {
if let Some(manifest_path) = manifest_path {
let path = gctx.cwd().join(manifest_path);
// In general, we try to avoid normalizing paths in Cargo,
// but in this particular case we need it to fix #3586.
let path = paths::normalize_path(&path);
if !path.exists() {
anyhow::bail!("manifest path `{}` does not exist", manifest_path.display())
} else if path.is_dir() {
let child_path = path.join("Cargo.toml");
let suggested_path = if child_path.exists() {
format!("\nhelp: {} exists", child_path.display())
} else {
"".to_string()
};
anyhow::bail!(
"manifest path `{}` is a directory but expected a file{suggested_path}",
manifest_path.display()
)
} else if !path.ends_with("Cargo.toml") && !crate::workspace::parser::is_embedded(&path) {
if gctx.cli_unstable().script {
anyhow::bail!(
"the manifest-path must be a path to a Cargo.toml or script file: `{}`",
path.display()
)
} else {View on GitHub (pinned to 98a09e7e7d)