Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upAllow optional dev-dependencies #1596
Comments
This comment has been minimized.
This comment has been minimized.
|
I was quite surprised that there was an explicit error when I tried this out to verify it, now I need to remember why I put that in there... |
This comment has been minimized.
This comment has been minimized.
|
Hm ok I think I remember now, and I believe my hesitation here was related to feature activation. For example it may be quite surprising to enable a feature which activates both dev and non-dev dependencies when a package is itself used as a dependency (e.g. no dev-deps are built). Should Cargo issue a warning/error in this case? Should Cargo silently ignore all activated dev-dependencies? |
This comment has been minimized.
This comment has been minimized.
|
Not sure. You're seeing the bigger picture much better than me, (thankfully!). I think I'll move to a mandatory dev dependency for now |
This comment has been minimized.
This comment has been minimized.
|
It could issue a warning if the feature only activates dev-dependencies. I'm already back from the "experiment" :-) I need it to be optional so that I can keep building tests on Rust 1.0, which doesn't have quickcheck_macros. How quickcheck works with testing functions (requires explicit cast to fn pointer for each tested predicate), the only sane way to use it is with macros. |
This comment has been minimized.
This comment has been minimized.
|
I think it'd be fine for now to ensure that a feature only activates only dependencies or the dev-dependencies, sending a hard error for now would allow us to possibly be more flexible in the future. |
alexcrichton
added
the
A-features
label
May 18, 2015
This comment has been minimized.
This comment has been minimized.
|
I'd like this in the context of platform dependent features that have dev-dependencies. |
huonw
referenced this issue
Oct 29, 2015
Merged
Only depend on quickcheck* when doing a nightly build #3
This comment has been minimized.
This comment has been minimized.
|
I wonder if this would be better served by having (This raises the question: do we want |
This comment has been minimized.
This comment has been minimized.
|
@huonw, that's a good idea! I like the sound of I don't think that we'd want Now all that being said, I also don't feel too bad about just silently not activating dev-dependencies if a feature includes it and it's not a direct dependency. That would at least cut down on the complexity of the manifest, which may be the best thing to optimize for here. |
This comment has been minimized.
This comment has been minimized.
|
Ran into another case where this would be handy. I added a dependency on clippy and compiletest to aster. Both only compile on nightly, so to keep things building on stable I had to make them optional. I enabled them with the While the fix was pretty simple (I just used another feature), really these dependencies are only necessary for testing my project, and have no use on any of my downstream users. This really does mean that they ought to be |
This comment has been minimized.
This comment has been minimized.
It does say that dev dependencies can't be optional lower down, but if this isn't going to be implemented any time soon then it may be nice to get rid of that suggestion (or link it to this issue so people know it's a future feature). |
This comment has been minimized.
This comment has been minimized.
mitchmindtree
commented
Apr 5, 2016
|
I've run into a similar use case to erickt: I've added an optional |
killercup
referenced this issue
Apr 15, 2016
Open
Why is --optional mutually exclusive with --build and --dev? #85
This was referenced Jun 29, 2016
dtolnay
referenced this issue
Feb 26, 2017
Closed
Combine serde_json and serde_json_tests into one crate #266
This comment has been minimized.
This comment has been minimized.
|
Add me to the pile. I have the same case as @bluss - wanting to have quickcheck tests. I also am replacing a crate that uses C code with pure Rust, so I'd like to have a dev-dependency on the replaced crate to run tests that ensure the behavior is the same between the two. Showing that I depend on the C crate would look really weird on crates.io though! I also have a dependency on competitor crates for the purposes of benchmarking. To solve all these in one fell swoop, I think I'm going to create a sub project that just uses my crate. This should work for me, but might not for everyone. |
This comment has been minimized.
This comment has been minimized.
|
Note that this is basically just blocked on getting the work done. I'd be most in favor of my previous comment, simply requiring that activating a feature can either enable a regular dependency or a dev-dependency, not both. |
This comment has been minimized.
This comment has been minimized.
|
What would need to be done for this? I'd be willing to try my hand at it. |
This comment has been minimized.
This comment has been minimized.
stale
bot
commented
Sep 18, 2018
|
As there hasn't been any activity here in over 6 months I've marked this as stale and if no further activity happens for 7 days I will close it. I'm a bot so this may be in error! If this issue should remain open, could someone (the author, a team member, or any interested party) please comment to that effect? The team would be especially grateful if such a comment included details such as:
Thank you for contributing! (The cargo team is currently evaluating the use of Stale bot, and using #6035 as the tracking issue to gather feedback.) If you're reading this comment from the distant future, fear not if this was closed automatically. If you believe it's still an issue please leave a comment and a team member can reopen this issue. Opening a new issue is also acceptable! |
stale
bot
added
the
stale
label
Sep 18, 2018
This comment has been minimized.
This comment has been minimized.
|
I believe this is still relevant. |
stale
bot
removed
the
stale
label
Sep 19, 2018
This comment has been minimized.
This comment has been minimized.
|
This is a feature request and there seems to be general consensus that it would be nice to have. It should be labeled as https://github.com/rust-lang/cargo/labels/Feature%20accepted so that stalebot leaves this alone. |
dwijnand
added
the
C-feature-request
label
Sep 19, 2018
This comment has been minimized.
This comment has been minimized.
darkstalker
commented
Feb 10, 2019
•
|
This would be a nice to have when you're playing with nightly-only crates as a separate nightly feature set. Currently you can't use nightly-only crates on your dev-dependencies without breaking your stable build. The current workaround is putting those crates on your regular dependencies under a "nightly" feature, but that's suboptimal. |
This comment has been minimized.
This comment has been minimized.
phyber
commented
Feb 10, 2019
|
While attempting to write some tests where the tests were depending on a testing crate that was nightly only just now, I was quite surprised when Rust told me I couldn't have optional |
bluss commentedMay 9, 2015
Quickcheck test cases take a very long time to build (minutes) compared to the rest of my tests that take seconds.
For this reason, I use quickcheck as an optional regular dependency. It's not used in regular cargo build and cargo test.
Using an optional dev-dependency would be more correct (and info on crates.io would be more correct).