{"record":{"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":null,"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/eb98b54bc9f3c74519f43d066cb3fd02ebc88df0/src/util/important_paths.rs#L25-L46","documentation":"find_project_manifest_exact(pwd, file) checks for a specific named file directly in pwd and bails if it is absent. Unlike the ancestor-walking variant, this checks exactly one directory.","triggerScenarios":"An internal lookup for a concrete file (e.g. a workspace member's manifest, Cargo.lock, or a patch target) where the file does not exist in the specified directory.","commonSituations":"Referencing a path member in Cargo.toml that was deleted or not yet created; a patch table pointing at a missing manifest; an outdated workspace layout after a refactor.","solutions":["Confirm the file exists at the exact pwd given (not a subdirectory or ancestor).","Fix the manifest reference (members/patch/exclude) to the real path.","Recreate the missing file if it was accidentally deleted."],"exampleFix":"# before (Cargo.toml)\n# [workspace]\n# members = [\"crates/missing\"]\n\n# after\n# [workspace]\n# members = [\"crates/present\"]   # corrected path","handlingStrategy":"validation","validationCode":"use std::path::Path;\n\nfn require_file_in_dir(dir: &Path, file: &str) -> Result<PathBuf, String> {\n    let p = dir.join(file);\n    if p.is_file() { Ok(p) } else { Err(format!(\"{file} not found in {}\", dir.display())) }\n}","typeGuard":"fn file_present(dir: &std::path::Path, file: &str) -> bool {\n    dir.join(file).is_file()\n}","tryCatchPattern":null,"preventionTips":["Keep workspace member paths in Cargo.toml in sync with the on-disk layout.","After moving/renaming crates, update members/patch/exclude immediately.","Add a CI check that every declared member path resolves."],"tags":["paths","manifest","workspace"],"backgroundTag":null,"analyzedSha":"eb98b54bc9f3c74519f43d066cb3fd02ebc88df0","analyzedAt":"2026-08-11T17:42:36.556Z","contentChangedAt":"2026-08-11T17:42:36.556Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}