{"id":"7861add82028a269","repo":"rust-lang/cargo","slug":"path-is-not-a-blob-in-the-git-repo","errorCode":null,"errorMessage":"path `{}` is not a blob in the git repo","messagePattern":"path `(.+?)` is not a blob in the git repo","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/sources/registry/git_remote.rs","lineNumber":356,"sourceCode":"            registry: &GitRegistry<'_>,\n            path: &Path,\n            index_version: Option<&str>,\n        ) -> CargoResult<LoadResponse> {\n            let repo = registry.repo()?;\n            let repo = repo.as_ref().unwrap();\n            let tree = registry.tree()?;\n            let entry = tree.get_path(path);\n            let entry = entry?;\n            let git_file_hash = Some(entry.id().to_string());\n\n            // Check if the cache is valid.\n            if index_version.is_some() && index_version == git_file_hash.as_deref() {\n                return Ok(LoadResponse::CacheValid);\n            }\n\n            let object = entry.to_object(repo)?;\n            let Some(blob) = object.as_blob() else {\n                anyhow::bail!(\"path `{}` is not a blob in the git repo\", path.display())\n            };\n\n            Ok(LoadResponse::Data {\n                raw_data: blob.content().to_vec(),\n                index_version: git_file_hash,\n            })\n        }\n\n        loop {\n            return match load_helper(&self, path, index_version) {\n                Ok(result) => Ok(result),\n                Err(_) if !self.is_updated() => {\n                    // If git returns an error and we haven't updated the repo,\n                    // return pending to allow an update to try again.\n                    self.needs_update.set(true);\n                    self.update()?;\n                    continue;\n                }","sourceCodeStart":338,"sourceCodeEnd":374,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/sources/registry/git_remote.rs#L338-L374","documentation":"When reading a crate's metadata from the git-based registry index, `GitRegistry::load_helper` (src/sources/registry/git_remote.rs:344) resolves the tree entry at `path` and asserts it is a `Blob`. If `entry.to_object(repo).as_blob()` returns `None` (the object is a tree, commit, submodule, or tag object instead), Cargo bails. The index is expected to store one JSON-line blob per crate path, so a non-blob indicates a malformed/corrupt index.","triggerScenarios":"A registry index git repository whose path entry for a crate resolves to a directory (tree) or a submodule rather than a file — e.g. a hand-rolled/misbuilt private registry that committed a folder instead of a file, or a corrupt/shallow clone of the index. Reached via `load()` in `git_remote.rs`.","commonSituations":"Custom/private registries built incorrectly (folder where a JSON-line file should be); a partially-cloned or corrupted `~/.cargo/registry/index/` git checkout; an index that added a submodule path colliding with a crate name.","solutions":["Force a clean re-clone of the registry index: remove `~/.cargo/registry/index/<registry-name>/` and run `cargo fetch`.","If you operate the registry, audit the index repository for entries that are directories/submodules instead of JSON-line blobs at the offending path.","Verify the index isn't a shallow/partial clone (the error-recovery path at line 368 already retries after an update; if it persists the index content itself is wrong)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep registry index clones clean: remove and re-clone `~/.cargo/registry/index/<reg>` on suspicion.","If you operate a private git-based registry, ensure each crate path is a JSON-line blob, never a directory/submodule.","Avoid shallow/partial clones of the index repository."],"tags":["cargo","registry","git-index","validation"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}