{"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":"anyhow::Error","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/0e07a155371a6ce88ae53a2c00df940280c09a67/src/util/important_paths.rs#L4-L40","documentation":"find_root_manifest_for_wd walks cwd and all ancestors looking for `Cargo.toml`. If none is found but a lowercase `cargo.toml` exists somewhere in that ancestor chain, Cargo reports it and asks the user to rename — because on case-sensitive filesystems (Linux) `cargo.toml` is not recognized.","triggerScenarios":"Running cargo in a directory tree where the manifest was mistakenly named `cargo.toml` (lowercase) instead of `Cargo.toml`, typically after copying a project from a case-insensitive filesystem (macOS/Windows) to Linux.","commonSituations":"Project created/renamed on macOS or Windows where `cargo.toml` and `Cargo.toml` are the same file, then deployed to Linux; a typo when creating the manifest; tooling that lowercased the filename.","solutions":["Rename the file: `mv cargo.toml Cargo.toml`.","On case-insensitive FS, use `git mv cargo.toml Cargo.toml` or a two-step rename (`mv cargo.toml tmp && mv tmp Cargo.toml`) to actually change the case.","Re-run cargo from the project root after renaming."],"exampleFix":"# before: project contains ./cargo.toml\nmv cargo.toml Cargo.toml\n# after: cargo build works","handlingStrategy":"validation","validationCode":"use std::path::Path;\nfn warn_lowercase_manifest(cwd: &Path) {\n    for d in cargo_util::paths::ancestors(cwd, None) {\n        if d.join(\"cargo.toml\").exists() && !d.join(\"Cargo.toml\").exists() {\n            eprintln!(\"warning: found lowercase cargo.toml in {}; rename to Cargo.toml\", d.display());\n        }\n    }\n}","typeGuard":"fn has_lowercase_cargo_toml(cwd: &std::path::Path) -> bool {\n    cargo_util::paths::ancestors(cwd, None)\n        .any(|d| d.join(\"cargo.toml\").exists())\n}","tryCatchPattern":"match find_root_manifest_for_wd(cwd) {\n    Err(e) if e.to_string().contains(\"found cargo.toml\") => {\n        eprintln!(\"rename cargo.toml -> Cargo.toml (case-sensitive FS)\");\n        return Err(e);\n    }\n    r => r,\n}","preventionTips":["Always create manifests as `Cargo.toml` (capital C, capital T).","On case-insensitive FS, use `git mv` with a two-step rename to fix case.","Add a pre-commit/CI check that no `cargo.toml` exists in the tree."],"tags":["filesystem","manifest","case-sensitivity","path"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}