-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Ability to disable individual default features #3126
Comments
Yeah it's true that default features are a very weighty decision and are quite difficult to reverse. I don't think we can add the ability to force-disable them, however, because how would we know whether a dependency actually needs the feature or not? |
@alexcrichton, maybe this is a bigger change then I'd expected, am not very experienced using Cargo. Could dependencies list features they require? |
Dependencies already do, the |
In that case wouldn't it be possible to disable a default - having the same behavior as if you explicitly listed all defaults, without the one(s) which have been requested to be disabled? |
Yeah you can disable default features with |
This is a backward-compatiblity hazard. E.g.: It seems that The better way to handle that would be that each crate has a list of default features that it does not require. This way, default features can be added in the future. |
I don't know about In for you may want to build FFMPEG with patented codecs or not. You may want to build a video editor with FFMPEG or not. |
Note that I don't talk about hard-disabling dependency feature, but rather the equivalent of today's |
@tbu- the idea seems sound to me at least! |
I'd especially like this to work on command line. Here's a proposal: Features prefixed with
Currently:
Proposed:
e.g. given [features]
default = ["foo", "bar"]
foo = []
bar = []
quz = []
|
This would also be very useful for testing e.g. (Though ofc you do need to worry about specifying the interaction with feature dependencies.) |
Going to do a quick brain dump since this has been on my mind... When it comes to evolving features without a breaking change, the biggest hazard is taking functionality that already existed and making a new feature from it. Existing features can already be split if you are ok with not reusing existing names though deprecation support would help a lot. In cargo's existing model of If we had started from scratch inventing default features, another approach to breaking existing functionality into a feature would be if we allow subtracting features from
I think limiting the scope of feature opt-outs and ensuring design keeps the intent clear can overcome these challenges. I also think we can transition to this even if we didn't start with this. A rough outline of my proposal
It would be interesting to see if this would help with Of course, there are details to be worked out and bike shedding to be done. Other benefits
Open questions
|
FWIW I would expect
Yes, it's removing the requirement, not the feature itself. I agree that opting out of future A |
For this to work, it could only have that affect within the current crate's resolving of features. I worry these semantics are too close in semantics to asserting that a feature won't be present at all (remove requirement everywhere) that it could be confusing. I also think it has the chance to break people. I'm going to expand on a case in RFC 3146. Say I have a dependency with
and I depend on it with And later the dependency changes it to
Then according to these semantics, |
not by my intuitive understanding, though explaining it is a bit difficult. .... also wait we set |
|
I assumed we didn't either but I went and tested it. We only set it if the user explicitly mentions a |
Wouldn't this still be a semver breakage for |
At RustConf, one of the problems that was pointed out is that Quick thoughts
|
This is due to the mutually exclusive features in rkyv which we expose now. `--all-features` will now activate them and the crate will fail to compile rkyv. We work around this by defining an explicit list of all mutually exclusive features to. Unfortunately there isn't an easy way to share env variables among different YAML files (actions/runner#655). There also isn't a good way to specify --all-features minus "just a few" (rust-lang/cargo#3126) aside from giving the complete list. Signed-off-by: Gerd Zellweger <[email protected]>
This is due to the mutually exclusive features in rkyv which we expose now. `--all-features` will now activate them and the crate will fail to compile rkyv. We work around this by defining an explicit list of all mutually exclusive features to. Unfortunately there isn't an easy way to share env variables among different YAML files (actions/runner#655). There also isn't a good way to specify --all-features minus "just a few" (rust-lang/cargo#3126) aside from giving the complete list. Signed-off-by: Gerd Zellweger <[email protected]>
This is due to the mutually exclusive features in rkyv which we expose now. `--all-features` will now activate them and the crate will fail to compile rkyv. We work around this by defining an explicit list of all mutually exclusive features to. Unfortunately there isn't an easy way to share env variables among different YAML files (actions/runner#655). There also isn't a good way to specify --all-features minus "just a few" (rust-lang/cargo#3126) aside from giving the complete list. Signed-off-by: Gerd Zellweger <[email protected]>
This is due to the mutually exclusive features in rkyv which we expose now. `--all-features` will now activate them and the crate will fail to compile rkyv. We work around this by defining an explicit list of all mutually exclusive features to. Unfortunately there isn't an easy way to share env variables among different YAML files (actions/runner#655). There also isn't a good way to specify --all-features minus "just a few" (rust-lang/cargo#3126) aside from giving the complete list. Signed-off-by: Gerd Zellweger <[email protected]>
This is due to the mutually exclusive features in rkyv which we expose now. `--all-features` will now activate them and the crate will fail to compile rkyv. We work around this by defining an explicit list of all mutually exclusive features to. Unfortunately there isn't an easy way to share env variables among different YAML files (actions/runner#655). There also isn't a good way to specify --all-features minus "just a few" (rust-lang/cargo#3126) aside from giving the complete list. Signed-off-by: Gerd Zellweger <[email protected]>
This is due to the mutually exclusive features in rkyv which we expose now. `--all-features` will now activate them and the crate will fail to compile rkyv. We work around this by defining an explicit list of all mutually exclusive features to. Unfortunately there isn't an easy way to share env variables among different YAML files (actions/runner#655). There also isn't a good way to specify --all-features minus "just a few" (rust-lang/cargo#3126) aside from giving the complete list. Signed-off-by: Gerd Zellweger <[email protected]>
This is due to the mutually exclusive features in rkyv which we expose now. `--all-features` will now activate them and the crate will fail to compile rkyv. We work around this by defining an explicit list of all mutually exclusive features to. Unfortunately there isn't an easy way to share env variables among different YAML files (actions/runner#655). There also isn't a good way to specify `--all-features` minus "just a few" (rust-lang/cargo#3126) aside from giving the complete list. Signed-off-by: Gerd Zellweger <[email protected]>
This is due to the mutually exclusive features in rkyv which we expose now. `--all-features` will now activate them and the crate will fail to compile rkyv. We work around this by defining an explicit list of all mutually exclusive features to. Unfortunately there isn't an easy way to share env variables among different YAML files (actions/runner#655). There also isn't a good way to specify `--all-features` minus "just a few" (rust-lang/cargo#3126) aside from giving the complete list. Signed-off-by: Gerd Zellweger <[email protected]>
This is due to the mutually exclusive features in rkyv which we expose now. `--all-features` will now activate them and the crate will fail to compile rkyv. We work around this by defining an explicit list of all mutually exclusive features to. Unfortunately there isn't an easy way to share env variables among different YAML files (actions/runner#655). There also isn't a good way to specify `--all-features` minus "just a few" (rust-lang/cargo#3126) aside from giving the complete list. Signed-off-by: Gerd Zellweger <[email protected]>
This is due to the mutually exclusive features in rkyv which we expose now. `--all-features` will now activate them and the crate will fail to compile rkyv. We work around this by defining an explicit list of all mutually exclusive features to. Unfortunately there isn't an easy way to share env variables among different YAML files (actions/runner#655). There also isn't a good way to specify `--all-features` minus "just a few" (rust-lang/cargo#3126) aside from giving the complete list. Signed-off-by: Gerd Zellweger <[email protected]>
This is due to the mutually exclusive features in rkyv which we expose now. `--all-features` will now activate them and the crate will fail to compile rkyv. We work around this by defining an explicit list of all mutually exclusive features to. Unfortunately there isn't an easy way to share env variables among different YAML files (actions/runner#655). There also isn't a good way to specify `--all-features` minus "just a few" (rust-lang/cargo#3126) aside from giving the complete list. Signed-off-by: Gerd Zellweger <[email protected]>
I just ran into this again: rustls (and, downstream of that, tokio-rustls) switched the default crypto provider in their latest releases (0.23 and 0.26 respectively), with the new releases allowing downstream users to switch crypto provider dependencies via Cargo features. I upgraded tokio-rustls and used |
I think there is solid interest in this. The problem is availability for someone to go through the design process. For myself, I already have about a years worth of design work I've committed to. (this is in a similar boat to mutually exclusive, global features) |
So like, start with a pre-RFC on internals and work from there? |
Yes, though first making sure to read over this thread so any nuance in it gets captured. |
I don't think a third-party solution will be accepted by the Cargo team. My two-year old rust-lang/rfcs#3283 would have solved it, in a way that other people are already able to hack around Cargo's lack of proper support for default-features: https://slint.dev/blog/rust-adding-default-cargo-feature. It was closed for being too complex, but I think it's the minimum complexity to make such a feature work at all. Another approach at rust-lang/rfcs#3347 has stalled for 1.5 years. |
To make it clearer to users that this doesn't disable features globally I suggest a couple of mitigations:
|
This comment has been minimized.
This comment has been minimized.
I have made a feature request that could be possible relevant here: #14866 |
This would be very useful for library authors.
It's kinda garbage, but it works |
The current documentation here: http://doc.crates.io/manifest.html states:
This is quite rigid, since it means you can't make a small adjustment to defaults - where a program may have multiple options which aren't related.
It also means if I use a 3rd party package with modified defaults, after an update I need to check if defaults where added which I might want to enable.
Note, I asked this question on stackoverflow, it was suggested to open an issue here:
http://stackoverflow.com/questions/39734321
The text was updated successfully, but these errors were encountered: