Skip to content

Inconsistency with publishing/vendoring listing of files #9555

@alexcrichton

Description

@alexcrichton

Currently I'm seeing some weird behavior in Cargo with respect to vendoring and publishing. Notably this project will succeed to compile but then fail to compile with a vendored build:

$ cargo new foo
$ cd foo
$ echo 'zstd-sys = "=1.6.0"' >> Cargo.toml
$ cargo build
...
    Finished dev [unoptimized + debuginfo] target(s) in 30.45s
$ mkdir .cargo
$ cargo vendor >> .cargo/config.toml
$ cargo build
error: failed to run custom build command for `zstd-sys v1.6.0+zstd.1.5.0`

Caused by:
  process didn't exit successfully: `/Users/acrichton/code/foo/target/debug/build/zstd-sys-2992c87aa8f96b70/build-script-build` (exit code: 101)
  --- stderr
  thread 'main' panicked at 'Folder 'zstd/lib' does not exists. Maybe you forgot to clone the 'zstd' submodule?', /Users/acrichton/code/foo/vendor/zstd-sys/build.rs:180:13
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Sure enough the zstd folder is indeed missing from the vendored checkout. Some other tidbits:

I believe the problem here is that cargo vendor uses list_files to list the files that are going to be used for publication/building, and something funny is happening here with the presence of a .git folder. For example checking out zstd-sys and running cargo package -v does indeed vendor the zstd folder. If you delete the zstd/.git folder, however, and then run cargo package -v the zstd folder is not included. This I think best simulates what's happening with the registry because it's presumably published from a source checkout (therefore including zstd), but it's then vendored from a checkout without .git (what was downloaded from crates.io). This means that vendors don't have the zstd folder but downloads from crates.io do.

I haven't dug too much into this but the bug is likely around list_files and how the exclude directory is handled relative to discovered submodules. We should probably warn about this or handle this differently at publication time, ideally publication and vendoring would work with similar sets of files.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions