Skip to content

Cargo vendor doesn't include dependency's hidden files #13662

Open
@joshuachp

Description

@joshuachp

Problem

Vendoring a dependency ignores hidden files present in the published crate and that are required to build it.

Steps

  1. Create a library dependency or crate that include_str!(".hidden") (e.g. test-dep-cargo-hidden)
  2. This crate need to be published on a registry, the crate will include the .hidden file
  3. Create another crate that uses the published dependency
  4. Use cargo vendor and in the vendor directory the .hidden file is missing
  5. Building with the vendor will fail, while normal builds will succeed

Possible Solution(s)

Vendoring should probably include all the files of the published package.

I believe those line caused this discrepancy:

if no_include_option && git_repo.is_none() {
// no include option and not git repo discovered (see rust-lang/cargo#7183).
exclude_builder.add_line(None, ".*")?;
}

This will cause the publish command to list all the files in the git repo of the dependency, while the vendor will use the sparse cache, which is not a git repository, to copy the files.

Notes

An example of this is having a dependency using sqlx offline files that are stored in the .sqlx/ directory.

Relevant documentation, issues and PRs I found:

Version

cargo 1.77.0 (3fe68eabf 2024-02-29)
release: 1.77.0
commit-hash: 3fe68eabf93cbf3772bbcad09a9206c783e2de3f
commit-date: 2024-02-29
host: x86_64-unknown-linux-gnu
libgit2: 1.7.2 (sys:0.18.2 vendored)
libcurl: 8.5.0-DEV (sys:0.4.70+curl-8.5.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: NixOS 24.5.0 [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions