Dependencies based on profile

I have some dependencies which I only need in non-release mode

Similarly, using them is behind a #[cfg(debug_assertions)] conditional compilation

Is there a way to specify these dependencies without relying on like a "dev" feature?

(fwiw the reason I want to avoid the feature is because I have multiple crates in a workspace, and I don't think it's possible to specify features on the workspace)

Nope. Build/dev/normal is the all you get.

1 Like

Oh... bummer. Relevant snippets from the docs in case anyone else stumbles upon this:

Dev-dependencies are not used when compiling a package for building, but are used for compiling tests, examples, and benchmarks.
...
Build dependencies will likewise not be available to the package itself unless listed under the dependencies section as well

So, a gotcha that caught me off guard- "dev" here doesn't mean "development mode", it means something else.

Features it is. This leads to another question - is there any way to pass a feature down through a workspace to all the member crates? (assuming all the member Cargo.toml's are set up with that same feature name)

Trying to follow the issue at https://github.com/rust-lang/cargo/issues/5364

Seems like it's unresolved... currently there's no way to enable features in members of a virtual workspace?