Skip to content

Cargo dies when in worktree of bare repository #7876

@maurer

Description

@maurer

Problem
When building rustc from a downloaded tarball (in this case, 1.40.0) that is inside a worktree of a bare git repo, Cargo will notice the .git directory and attempt to list files and die while trying.

Steps

  1. Download a Rust source tarball
  2. Unpack it and check it into a git repository
  3. Create a bare clone of that git repository
  4. Use "git worktree" to create a checkout of the bare git repository.
  5. Attempt to build rustc (e.g. ./x.py install)

(This obviously isn't minimized, but is the original environment in which I encountered the problem. I expect the problem would occur when trying to use a path source in any worktree.)

Possible Solution(s)

  • Use list-tree based on the current worktree rather than list-files
  • Fall back to non-git base path sources in the event of a bare repo

Notes
This is related to #4131 but actually caused our CI to start failing because the backend switched to bare repos from normal clones to save disk.

I created a separate issue because it is not restricted to cargo publish and is not just a workflow issue.

Output of cargo version: cargo 1.40.0-dev

Metadata

Metadata

Assignees

Labels

A-gitArea: anything dealing with gitA-testing-cargo-itselfArea: cargo's testsC-bugCategory: bugS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or review

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions