-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It’s possible to build optional dependencies not listed in Cargo.lock #3629
Comments
Definitely looks like a bug! I think that this is only possible from the command line, right? |
Yes, for example adding |
Yeah the change here is that you shouldn't be able to activate a feature that wasn't already in the lock file. To that end you shouldn't be able to activate a transitive feature that wasn't already possible to activate via some local feature. |
For what it’s worth, html5ever uses a custom test harness crate (to support dynamically generated tests on stable Rust) which has optional features for stuff that uses unstable std APIs. It’s been very convenient to use |
Oh yeah this kind of feature should still be supported, but yeah you'll need some sort of feature locally to optionally enable a transitive feature. That'll ensure everything makes its way to the lock file and prevents weird bugs like updating the registry too often and such. |
So what’s the fix? Forbid |
Nah What wouldn't be allowed is activating |
#13100 raised a variation of this issue where it is possible to |
Another thought, it would be nice if the solution to this would detect if everything is a [package]
name = "foo"
version = "1.0.0"
edition = "2021"
[dependencies]
bar = {path = "bar"} Here, |
This is the opposite, I would like to be able to patch an unused optional dependency (which does not seems to be allowed anymore) |
#13100 (comment) mentions another recommendation that cargo could make here where it could suggest re-exporting a feature that enables the optional dependency, which tells the resolver to use it as a candidate. |
Note that the Cargo documentation currently gives a narrower rule:
I found this issue while trying to determine whether Cargo was working as intended when I found out I could specify an arbitrary feature of an arbitrary package in the dependency graph. It would be nice if this was documented more precisely, including the known issue, because where I started was determining whether I could use |
Test case: (run in a temporary directory)
Output in cargo 0.17.0-nightly (67e4ef1 2017-01-25)
Crates
c
andd
were compiled and used, but are not listed inCargo.lock
.The text was updated successfully, but these errors were encountered: