cargo-fuzz icon indicating copy to clipboard operation
cargo-fuzz copied to clipboard

Mistaking `dev-dependencies` for features?

Open valarauca opened this issue 4 years ago • 4 comments

I'm in a workspace, which understands where my fuzz crate is.

After running the

rustup override set nightly
cargo install -f cargo-fuzz

In the root of the work space I do:

$ cargo fuzz init
Error: ${SNIP}/rust_project/compressor/Cargo.toml (package.name) is malformed
$ cd fuzz
$ cargo fuzz init
Error: ${SNIP}/rust_project/compressor/Cargo.toml (package.name) is malformed

Hmm, okay. So I try another avenue

$ cargo fuzz list
fuzz_xxhash32_reference
fuzz_xxhash32_stream
$ cargo fuzz run fuzz_xxhash32_reference
error: failed to select a version for `xxhash`.
    . . .  required by package `fuzz v0.1.0 (${SNIP}/rust_projects/compressor/fuzz)`
versions that meet the requirements `=0.1.0` are: 0.10

the package `fuzz` depends on `xxhash`, with features: `twox-hash, getrandom` but `xxhash` does not have these features.

The xxhash/Cargo.toml which I'm depending on. The confusion is two fold:

  1. These aren't features. These are dev-dependencies which are feature gated.
  2. Within the fuzz/Cargo.toml I am indeed setting features.

So why am I importing dev-dependencies with default features? How do I fix this?


One other bug report:

If the crate which is preforming the fuzzing isn't named fuzz then you just can't do anything. I wanted to have a separate xxhash-fuzz. As lumping all local workspace crates into same fuzz-crate seemed wrong, namely separation of concerns.

valarauca avatar May 06 '20 19:05 valarauca

Error: ${SNIP}/rust_project/compressor/Cargo.toml (package.name) is malformed

cargo fuzz init should be run in the directory of your cargo project, not your cargo workspace

frewsxcv avatar May 17 '20 16:05 frewsxcv

though maybe we can ease that constraint, since it's sorta arbitrary

frewsxcv avatar May 17 '20 16:05 frewsxcv

cargo fuzz init should be run in the directory of your cargo project, not your cargo workspace

I change directory within the example:

$ cargo fuzz init
Error: ${SNIP}/rust_project/compressor/Cargo.toml (package.name) is malformed
$ cd fuzz
$ cargo fuzz init
Error: ${SNIP}/rust_project/compressor/Cargo.toml (package.name) is malformed

The error is the same irregardless of if I run it within the crate or workspace directory. Provided the crate is a member of a workspace.

My workspace Cargo.toml was well formed (as way my Cargo.toml within the fuzz crate), given the fact I could run $ cargo fuzz list within my fuzz crate, as well as other normal cargo workflow operations.

valarauca avatar May 17 '20 22:05 valarauca

cargo fuzz init should be run in the directory of your cargo project, not your cargo workspace

I change directory within the example:

$ cargo fuzz init
Error: ${SNIP}/rust_project/compressor/Cargo.toml (package.name) is malformed
$ cd fuzz
$ cargo fuzz init
Error: ${SNIP}/rust_project/compressor/Cargo.toml (package.name) is malformed

The error is the same irregardless of if I run it within the crate or workspace directory. Provided the crate is a member of a workspace.

My workspace Cargo.toml was well formed (as way my Cargo.toml within the fuzz crate), given the fact I could run $ cargo fuzz list within my fuzz crate, as well as other normal cargo workflow operations.

I'm getting the same issue with my Cargo.toml looking like:

version.workspace = true
authors.workspace = true
edition.workspace = true
rust-version.workspace = true
documentation.workspace = true
description.workspace = true
homepage.workspace = true
repository.workspace = true

joshua-auchincloss avatar Jun 05 '23 13:06 joshua-auchincloss