Skip to content

cargo publish has bad error message when explicit [[bench]] isn't in package.include #13456

Closed
@dhardy

Description

@dhardy

Problem

cargo publish fails

Steps

Using the latest rand commit:

$ cargo publish --dry-run
    Updating crates.io index
   Packaging rand v0.9.0-alpha.0 (/home/dhardy/projects/rand/rand)
    Updating crates.io index
   Verifying rand v0.9.0-alpha.0 (/home/dhardy/projects/rand/rand)
error: failed to verify package tarball

Caused by:
  failed to parse manifest at `/home/dhardy/projects/rand/rand/target/package/rand-0.9.0-alpha.0/Cargo.toml`

Caused by:
  can't find `uniform` bench at `benches/uniform.rs` or `benches/uniform/main.rs`. Please specify bench.path if you want to use a non-default path.

Possible Solution(s)

No response

Notes

The relevant part of the Cargo.toml:

[[bench]]
name = "uniform"
harness = false

This could have a path specified... but as far as I can tell, cargo publish is the only thing not happy to discover the default path (benches/uniform.rs).

Despite this, the benchmark works fine:

$ ls -l benches/uniform.rs 
-rw-r--r--. 1 dhardy dhardy 2696 Feb 13 11:39 benches/uniform.rs
$ cargo bench --bench uniform --features small_rng
   Compiling rand v0.9.0-alpha.0 (/home/dhardy/projects/rand/rand)
    Finished `bench` profile [optimized] target(s) in 2.28s
     Running benches/uniform.rs (target/release/deps/uniform-38f8da4b7c78a479)
samplei8/SmallRng/single
                        time:   [1.5141 ns 1.5143 ns 1.5145 ns]
[snip]

Steps

Version

cargo 1.78.0-nightly (fc1d58fd0 2024-02-09)
release: 1.78.0-nightly
commit-hash: fc1d58fd0531a57a6b942a14cdcdbcb82ece16f3
commit-date: 2024-02-09
host: x86_64-unknown-linux-gnu
libgit2: 1.7.2 (sys:0.18.2 vendored)
libcurl: 8.6.0-DEV (sys:0.4.71+curl-8.6.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Fedora 39 [64-bit]

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