cargo cannot read from local Git repositories with reftable #15184
Labels
A-git
Area: anything dealing with git
C-bug
Category: bug
S-blocked-external
Status: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix
Problem
Recent versions of Git have added a new backend for references called reftable. This backend does not store references as files, so it performs better and remains case-sensitive even on systems with case-insensitive file systems. (This is important if the remote has branches differing only in case and you're on a case-insensitive system.)
cargo, by default, uses libgit2, which does not support reftable. When cloning from a bare repository on the local system using reftable, cargo fails. (Cloning in this way could, for instance, be used to access a bare repository on a network file system mounted locally.)
Steps
With a relatively new Git (2.47 or newer, I think), run the following script:
Note that the output looks like this:
Note that this does work with
CARGO_NET_GIT_FETCH_WITH_CLI=true
:Possible Solution(s)
I'd recommend just using Git by default. This is an easy change to work around for right now, but as I've mentioned below, there are a bunch of other ugly edge cases where using reftable causes problems.
libgit2 is cool, but in general it sees far less investment than upstream Git, so most major forges are moving away from it. reftable will show up eventually, but it will be another case like #14942 where the support is a long time coming. (Full disclosure: I'm a regular contributor to Git and I have sent a few patches to libgit2.)
Notes
The reason this happens is that reftable is an extension to the repository. For v1 repositories (all those with extensions), a Git implementation must read the local config and immediately reject every operation on the repository if there's an extension it doesn't understand. While in this case that's obviously necessary because we can't read the refs, libgit2 is also unable to perform any operation at all on a repository with reftable, including opening the repository, so things like
cargo package
dirty worktree checking also fail if the local repository is using reftable.Version
The text was updated successfully, but these errors were encountered: