Skip to content

cargo vendor loses some nonempty directories #15080

@dtolnay

Description

@dtolnay

Problem

For example, this one: https://docs.rs/crate/bat/0.25.0/source/src/syntax_mapping/builtins/macos/

Steps

Confirm this directory exists in the published crate, as shown in the docs.rs link above.

$ curl -L https://crates.io/api/v1/crates/bat/0.25.0/download -o bat-0.25.0.crate

$ tar tf bat-0.25.0.crate bat-0.25.0/src/syntax_mapping/builtins/macos
bat-0.25.0/src/syntax_mapping/builtins/macos/.gitkeep

Now let's try vendoring.

# Cargo.toml
[package]
name = "repro-cargo"
edition = "2021"

[dependencies]
bat = "=0.25.0"
$ cargo vendor

$ ls vendor/bat/src/syntax_mapping/builtins/
bsd-family  common  linux  README.md  unix-family

"macos" is not there.

In bat-0.25.0's case, this actually breaks the crate (when built on macos from vendored sources).

error: failed to run custom build command for `bat v0.25.0`

Caused by:
  process didn't exit successfully: `target/debug/build/bat-126fec914d2804b6/build-script-main` (exit status: 1)
  --- stdout
  cargo:rerun-if-changed=build/
  cargo:rerun-if-changed=src/syntax_mapping/builtins/

  --- stderr
  Error: IO error for operation on src/syntax_mapping/builtins/macos: No such file or directory (os error 2)

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

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.86.0-nightly (088d49608 2025-01-10)
release: 1.86.0-nightly
commit-hash: 088d496082726091024f1689c124a0c3dccbd775
commit-date: 2025-01-10
host: x86_64-unknown-linux-gnu
libgit2: 1.9.0 (sys:0.20.0 vendored)
libcurl: 8.9.0-DEV (sys:0.4.74+curl-8.9.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Ubuntu 24.4.0 (noble) [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-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