{"id":"c7dcb73b6b0d0216","repo":"rust-lang/cargo","slug":"failed-to-find-entry-for-in-directory-source","errorCode":null,"errorMessage":"failed to find entry for `{}` in directory source","messagePattern":"failed to find entry for `(.+?)` in directory source","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/sources/directory.rs","lineNumber":236,"sourceCode":"            .get(&id)\n            .map(|p| &p.0)\n            .cloned()\n            .map(MaybePackage::Ready)\n            .ok_or_else(|| anyhow::format_err!(\"failed to find package with id: {}\", id))\n    }\n\n    async fn finish_download(&self, _id: PackageId, _data: Vec<u8>) -> CargoResult<Package> {\n        panic!(\"no downloads to do\")\n    }\n\n    fn fingerprint(&self, pkg: &Package) -> CargoResult<String> {\n        Ok(pkg.package_id().version().to_string())\n    }\n\n    fn verify(&self, id: PackageId) -> CargoResult<()> {\n        let packages = self.packages.borrow_mut();\n        let Some((pkg, cksum)) = packages.get(&id) else {\n            anyhow::bail!(\"failed to find entry for `{}` in directory source\", id);\n        };\n\n        for (file, cksum) in cksum.files.iter() {\n            let file = pkg.root().join(file);\n            let actual = Sha256::new()\n                .update_path(&file)\n                .with_context(|| format!(\"failed to calculate checksum of: {}\", file.display()))?\n                .finish_hex();\n            if &*actual != cksum {\n                anyhow::bail!(\n                    \"the listed checksum of `{}` has changed:\\n\\\n                     expected: {}\\n\\\n                     actual:   {}\\n\\\n                     \\n\\\n                     directory sources are not intended to be edited, if \\\n                     modifications are required then it is recommended \\\n                     that `[patch]` is used with a forked copy of the \\\n                     source\\","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/sources/directory.rs#L218-L254","documentation":"In the directory source `verify`: a `PackageId` passed to `verify` was not present in the source's in-memory package map (`packages.get(&id)` returned `None`). Directory sources are populated by scanning their `.cargo-checksum.json`/index; an unknown id means the package was never registered in that directory source.","triggerScenarios":"A `[source]` pointing at a directory (`directory = \"...\"`) that doesn't contain an entry for the requested package id — e.g. the vendored directory is missing a crate folder, or the id's name/version doesn't match any subdirectory. Reached when Cargo calls `Source::verify` on a directory source.","commonSituations":"Incomplete `cargo vendor` output (a crate folder deleted/missing); pointing `replace-with` at the wrong directory; a stale vendor directory after changing dependencies without re-running `cargo vendor`; case-sensitivity mismatch on case-insensitive filesystems.","solutions":["Re-run `cargo vendor` to regenerate the complete vendor directory.","Verify the directory path in `.cargo/config.toml` `[source.<name>] directory = ` points at the right location.","Check that every `[dependencies]` crate has a corresponding folder under the vendor directory."],"exampleFix":"# before: vendor dir missing crate folder\n# after\ncargo vendor vendor  # regenerates all required crates","handlingStrategy":"validation","validationCode":"# Verify the vendor dir contains every dependency before building offline:\ncargo metadata --format-version 1 | jq -r '.packages[].name' | sort -u > /tmp/needed\nls vendor | sort -u > /tmp/present\ncomm -23 /tmp/needed /tmp/present  # empty = OK","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Re-run `cargo vendor` whenever `Cargo.toml` dependencies change.","Commit the entire vendor dir (or regenerate it deterministically in CI).","Point `replace-with` at the correct absolute/relative directory path."],"tags":["directory-source","vendor","path","missing"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}