Skip to content

Vendored crate with git submodule may have something wrong with gitignore #13607

@yukiiiteru

Description

@yukiiiteru

Problem

When one crate (lib) uses jemalloc as a submodule and another crate (binary) uses that library, cargo vendor for the binary works, but some files with checksums are ignored by git.

If I run git clean -dfqx or push the repository and clone it to another location, the build fails.

I tried to reproduce it with my handwritten .gitignore but failed. Only jemalloc (with its gitignore) can reproduce the problem.

Steps

I've created repositories for reproducing it:

There is jemalloc as submodule in the lib.

To reproduce the problem, you can use the above binary crate:

git clone https://github.com/wfly1998/vendor-issue-reproduce.git
cd vendor-issue-reproduce
cargo vendor > .cargo/config
git add .
git commit -m "test"
git clean -dfqx # or try `git clean -dfnx` to show the ignored files
cargo build --offline # fails

My outputs:

$ git clean -dfnx
Would remove target/
Would remove vendor/is_odd/jemalloc/test/stress/cpp/

$ git clean -dfqx

$ cargo build --offline
error: failed to calculate checksum of: vendor-issue-reproduce/vendor/is_odd/jemalloc/test/stress/cpp/microbench.cpp

Caused by:
  failed to open file `vendor-issue-reproduce/vendor/is_odd/jemalloc/test/stress/cpp/microbench.cpp`

Caused by:
  No such file or directory (os error 2)

Possible Solution(s)

No response

Notes

No response

Version

$ cargo version --verbose
cargo 1.79.0-nightly (2fe739fcf 2024-03-15)
release: 1.79.0-nightly
commit-hash: 2fe739fcf16c5bf8c2064ab9d357f4a0e6c8539b
commit-date: 2024-03-15
host: x86_64-unknown-linux-gnu
libgit2: 1.7.2 (sys:0.18.2 vendored)
libcurl: 8.6.0-DEV (sys:0.4.72+curl-8.6.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Debian 10 (buster) [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-gitArea: anything dealing with gitC-bugCategory: bugCommand-vendorS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions