{"record":{"id":"cae0bde5bbcde376","repo":"rust-lang/cargo","slug":"could-not-find-in-or-any-parent-director","errorCode":null,"errorMessage":"could not find `{}` in `{}` or any parent directory, but found cargo.toml please try to rename it to Cargo.toml","messagePattern":"could not find `(.+?)` in `(.+?)` or any parent directory, but found cargo\\.toml please try to rename it to Cargo\\.toml","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/util/important_paths.rs","lineNumber":22,"sourceCode":"\n/// Finds the root `Cargo.toml`.\npub fn find_root_manifest_for_wd(cwd: &Path) -> CargoResult<PathBuf> {\n    let valid_cargo_toml_file_name = \"Cargo.toml\";\n    let invalid_cargo_toml_file_name = \"cargo.toml\";\n    let mut invalid_cargo_toml_path_exists = false;\n\n    for current in paths::ancestors(cwd, None) {\n        let manifest = current.join(valid_cargo_toml_file_name);\n        if manifest.exists() {\n            return Ok(manifest);\n        }\n        if current.join(invalid_cargo_toml_file_name).exists() {\n            invalid_cargo_toml_path_exists = true;\n        }\n    }\n\n    if invalid_cargo_toml_path_exists {\n        anyhow::bail!(\n            \"could not find `{}` in `{}` or any parent directory, but found cargo.toml please try to rename it to Cargo.toml\",\n            valid_cargo_toml_file_name,\n            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() {","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/rust-lang/cargo/blob/eb98b54bc9f3c74519f43d066cb3fd02ebc88df0/src/util/important_paths.rs#L4-L40","documentation":"find_root_manifest_for_wd walks ancestors of cwd looking for Cargo.toml. If it never finds the correctly-cased file but does encounter a lowercase cargo.toml somewhere up the tree, it reports the case mismatch — a common failure on case-sensitive filesystems.","triggerScenarios":"Running any cargo command from inside a directory tree where the manifest was created as `cargo.toml` (lowercase) on a case-sensitive filesystem (Linux default).","commonSituations":"File created on macOS/Windows and committed with wrong case; editor autocorrect lowercased the filename; clone on Linux of a repo with a misnamed manifest.","solutions":["Rename the file to Cargo.toml: `git mv cargo.toml Cargo.toml` (or plain mv if untracked).","On case-insensitive filesystems use `git mv -f` with a two-step rename to force the case change in git.","Verify with `ls -la | grep -i cargo.toml` that the correct case is present."],"exampleFix":"# before\n# ls\n# cargo.toml\n\n# after\n# git mv cargo.toml Cargo.toml\n# git commit -m \"Fix manifest filename casing\"","handlingStrategy":"validation","validationCode":"use std::path::Path;\n\nfn find_correctly_cased_manifest(cwd: &Path) -> Result<PathBuf, String> {\n    for dir in paths::ancestors(cwd, None) {\n        let p = dir.join(\"Cargo.toml\");\n        if p.is_file() { return Ok(p); }\n        if dir.join(\"cargo.toml\").is_file() {\n            return Err(format!(\"found lowercase cargo.toml at {}; rename to Cargo.toml\", dir.display()));\n        }\n    }\n    Err(\"no Cargo.toml found\".into())\n}","typeGuard":"fn manifest_case_is_correct(dir: &std::path::Path) -> bool {\n    dir.join(\"Cargo.toml\").is_file()\n}","tryCatchPattern":null,"preventionTips":["On case-sensitive filesystems, always create the manifest as `Cargo.toml` (capital C, capital T).","Add a CI lint that fails if any `cargo.toml` (lowercase) appears in the repo.","After cloning on Linux, run `git ls-files | grep -i 'cargo.toml'` to spot mis-cased manifests."],"tags":["manifest","paths","case-sensitivity","filesystem"],"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"}