{"id":"fb443e64aeb272f3","repo":"rust-lang/cargo","slug":"could-not-find-in","errorCode":null,"errorMessage":"Could not find `{}` in `{}`","messagePattern":"Could not find `(.+?)` in `(.+?)`","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/util/important_paths.rs","lineNumber":43,"sourceCode":"            cwd.display()\n        )\n    } else {\n        anyhow::bail!(\n            \"could not find `{}` in `{}` or any parent directory\",\n            valid_cargo_toml_file_name,\n            cwd.display()\n        )\n    }\n}\n\n/// Returns the path to the `file` in `pwd`, if it exists.\npub fn find_project_manifest_exact(pwd: &Path, file: &str) -> CargoResult<PathBuf> {\n    let manifest = pwd.join(file);\n\n    if manifest.exists() {\n        Ok(manifest)\n    } else {\n        anyhow::bail!(\"Could not find `{}` in `{}`\", file, pwd.display())\n    }\n}\n","sourceCodeStart":25,"sourceCodeEnd":46,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/util/important_paths.rs#L25-L46","documentation":"find_project_manifest_exact joins `file` to `pwd` and checks existence; if that exact file is not present it bails. Unlike find_root_manifest_for_wd this does not walk ancestors — it only looks in the single given directory for the named file.","triggerScenarios":"Calling cargo internals (or a path that resolves through them) requesting a specific manifest file in a specific directory where that file does not exist, e.g. looking for `Cargo.toml` in a workspace member path that lacks one.","commonSituations":"A workspace member referenced in the root manifest whose directory is missing its Cargo.toml; a typo in a member path; a vendored/checked-out dependency missing its manifest; stale workspace `members` glob pointing at an empty dir.","solutions":["Confirm the expected file exists in the target directory: `ls <dir>/<file>`.","Fix the workspace `members`/`default-members` paths in the root Cargo.toml.","Re-vendor or re-checkout the dependency that is missing its manifest.","Correct any typo in the directory or filename being requested."],"exampleFix":"# root Cargo.toml before\nmembers = [\"crates/foo\", \"crates/bar\"]\n# but crates/bar/ has no Cargo.toml\n\n# after: remove the missing member or add its manifest\nmembers = [\"crates/foo\"]","handlingStrategy":"validation","validationCode":"use std::path::Path;\nfn ensure_member_manifest(pwd: &Path, file: &str) -> Result<(), anyhow::Error> {\n    let p = pwd.join(file);\n    if !p.exists() { anyhow::bail!(\"{p:?} missing; check workspace `members` paths\"); }\n    Ok(())\n}","typeGuard":"fn member_manifest_present(pwd: &std::path::Path, file: &str) -> bool {\n    pwd.join(file).exists()\n}","tryCatchPattern":"match find_project_manifest_exact(pwd, file) {\n    Err(e) if e.to_string().contains(\"Could not find\") => {\n        eprintln!(\"{file} missing in {pwd:?}; verify workspace members/globs\");\n        return Err(e);\n    }\n    r => r,\n}","preventionTips":["Keep workspace `members` globs in sync with the actual directory layout.","Re-vendor/check out members that go missing.","Lint for member directories lacking a Cargo.toml in CI."],"tags":["filesystem","manifest","workspace","path"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}