Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upNew behavior of `--feature` + `--package` combination #5364
Comments
This comment has been minimized.
This comment has been minimized.
|
#5362 is I think the manifestation of the old odd behavior. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
I think #4942 is also this issue. |
This comment has been minimized.
This comment has been minimized.
|
And #4753 as well |
This comment was marked as resolved.
This comment was marked as resolved.
|
(typo in the issue description: |
matklad
changed the title
New behavior of `--feature` + `--pacakge` combination
New behavior of `--feature` + `--package` combination
Apr 16, 2018
iliekturtles
referenced this issue
Apr 25, 2018
Open
Features don't interact well with workspace crates #82
This comment has been minimized.
This comment has been minimized.
|
This broke Servo unfortunately, so we probably would need to back this out, at least in this, maximally aggressive, form. However, I wonder what we plan to do with feature-selection problems in general? I assume that we want to eventually fix the main problem with features. Currently, features are global per compilation, and that means that features bleed from dev-deps to normal deps and that Fixing that, however, would be a breaking change: suddenly, Cargo would select a smaller set of features :-( But, if we do fix that, then behavior of the combination of The core question I think is do we feel comfortable with eventually changing the set of activated features? If we are, then I think we can modify current fix to not flatly error-out, but to ignore the features argument for several packages, printing a warning like "this was accepted in previous versions of Cargo and activated features in surprising way, and not it is ignored". |
This comment has been minimized.
This comment has been minimized.
pravic
commented
Apr 28, 2018
•
Used to work. And expectation was "Enable the specified set of futures for crates that support it".
Now we see this (thanks to CI to catch it soon and not after Rust release) and it does not matter whether all of workspace members have How come that the original issue ( |
This comment has been minimized.
This comment has been minimized.
Not that this expectation is wrong. What actually happens is that the feature is enabled only for the package in the current working directory. In other words, it is irrelevant whether all members have the
That was definitely an oversight on my part :( |
This comment has been minimized.
This comment has been minimized.
|
Here's a small example which demonstrates the difference in behavior: https://github.com/matklad/features-behavior |
This comment has been minimized.
This comment has been minimized.
|
added a commit
that referenced
this issue
Apr 28, 2018
added a commit
that referenced
this issue
Apr 28, 2018
added a commit
that referenced
this issue
Apr 28, 2018
koute
referenced this issue
Apr 29, 2018
Closed
`--features` doesn't work for `cargo metadata` in projects with workspaces #5439
This comment has been minimized.
This comment has been minimized.
|
Breaking changes to stable functionality are not acceptable. Please revert and find a way to make this opt-in. However weird and subjectively broken the old behavior is, it has been around for more than long enough that many large projects have built work-arounds that came to rely on it. It’s easy to say this in hindsight, but I think it shouldn’t be surprising that a change like this is definitely gonna break some builds. #5390, the PR that enable this change by default, says:
At the time of that writing, that forum thread was 2 days old and had responses from three individuals, one of them saying their build is broken. How is this "positive" enough? But even if that discussion had received community-wide attention, breakage like this without opt-in is still unacceptable IMO. The projects most likely to be affected are those with complex build system that involve many crates. They may or may not be involved in the day-to-day development of Rust and Cargo. Now if we are going to make a change around feature selection, in addition to being opt-in (possibly through |
Ortham
referenced this issue
May 11, 2018
Closed
cargo build --all --all-features in a non-virtual workspace ignores features not present in the root crate #5518
RazrFalcon
referenced this issue
Jun 23, 2018
Closed
Building rendersvg with cairo backend results in "built without any backends" #69
matklad
referenced this issue
Jun 26, 2018
Open
Virtual manifest doesn't work with sub-crate's features #4942
alexcrichton
referenced this issue
Aug 2, 2018
Open
Specified features are silently ignored when building from the root of a workspace with default-members #5849
gnzlbg
referenced this issue
Sep 13, 2018
Closed
enable assert_instr on wasm32 vector splat operations #569
This comment has been minimized.
This comment has been minimized.
gnzlbg
commented
Sep 13, 2018
•
|
Because of this cargo bug |
This comment has been minimized.
This comment has been minimized.
gnzlbg
commented
Sep 13, 2018
•
This is incorrect. Breaking changes to stable functionality are acceptable if the functionality is broken, otherwise we couldn't ever fix any bugs if the behavior of the fix could be observed by current crates. The question that we have to resolve here is whether this functionality is broken or not. If it isn't broken, you are correct in that we cannot fix it. But if it is broken, we can fix it. Depending on the impact of the fix, we might have to warn first for a sufficiently long time before applying the fix, but fixing it is possible and does not require a new edition, although we could use one to implement the fix. Currently, when I have a workspace with a package
compiles |
This comment has been minimized.
This comment has been minimized.
|
We can split hairs about the finer details what the stability promise means, but in this particular case it is clear that a number of projects have been negatively impacted by this change until it was reverted, with no clear migration path.
I don’t think that’s good enough. A change of this importance needs to be opt-in, either with a dedicated line in the workspace’s manifest or as part of an edition switch. |
This comment has been minimized.
This comment has been minimized.
gnzlbg
commented
Sep 13, 2018
•
After going through this and related issues, including the servo one, the only thing that's clear to me is that this change has broken the build of some projects. The fact that these projects have been negatively impacted by this change is not at all clear to me, since I haven't find much information about why exactly the build broke for those projects and whether the previous behavior was even actually intended. FWIW this change would have broken the build of |
This comment has been minimized.
This comment has been minimized.
|
Just to not get things mixed up:
Breaking the build in a way unrelated to unstable features is negative impact. I don’t remember the details at this point, but we had found work-arounds for the current behavior’s weirdness, and in applying those work-arounds had come to rely on the current behavior. The new behavior was present in Nightly for about two weeks (between rust-lang/rust#49939 and rust-lang/rust#50344). I don’t know why the |
CryZe
referenced this issue
Sep 27, 2018
Closed
--no-default-features doesn't work with workspaces #6107
This comment has been minimized.
This comment has been minimized.
dhardy
commented
Oct 1, 2018
I don't think the status quo is good enough either; this bug should have been fixed a long time ago. But I agree that the #5353 may not be the ideal solution.
This is obviously a problem, because people have used expressions like
We could implement this expectation. On the positive side, it should only break tests if those tests were in fact testing broken code. On the negative side, a typo or forgetting to add a feature to a sub-package could go unnoticed. But what might be a reasonable compromise would be to enable features specified by Summary: a proper fix probably will cause some breakage to existing build systems. But it should correct mis-conceptions and should be very easy for users to fix. IMHO it is worth suffering some breakage here. Note also that the breakage will mostly only affect continuous integration testing, and not users building/testing packages manually and depending on them transitively. |
This comment has been minimized.
This comment has been minimized.
Breakage and fix v.s. neither are not the only options! We can have a configuration in the workspace’s root
IIRC this was not the case with Servo, we could build at all. I’m not sure why you make this distinction by the way, CI is designed to be as close as possible to other usage. |
This comment has been minimized.
This comment has been minimized.
gnzlbg
commented
Oct 1, 2018
•
|
We are at an impasse here. If we make this change opt-in, we don't break any code in the wild. This is good because it does not break code in the wild that's correctly working as intended. At the same time, this is bad because there is code in the wild that's silently broken, and this change does neither fix it nor alert the maintainers of this code that it needs fixing. If we make this opt-out, we break the broken code, which is good, but we also break the correct code, which is bad. Honestly, we are here because the current behavior is too implicit, different people expected it to behave differently, and things just silently happened to work for everybody, resulting both in correct and incorrect code. A compromise solution to this problem might be to just fix the implicitness. We could just add two flags, that enable the different behaviors, and just start warning that all projects should explicitly specify which behavior they want somehow (how exactly is something we can decide later). That will be better than what we currently have, it does not break any code, and it does let people with broken code know that their code might be broken. Whether we ever turn this warning into an error or not, and how we would do that, is the most controversial part of this issue, and something that we don't really have to discuss right now. |
This comment has been minimized.
This comment has been minimized.
dhardy
commented
Oct 1, 2018
|
Then I assumed wrong about Servo... why are you using
IMO this is an ugly solution — many users will forget or not know about this, then be surprised when down the road they find Cargo's configuration and usage is already complex with significant documentation users need to read to understand various features. Adding further configuration options should not be a preferred option IMO.
At least this doesn't implicitly do the wrong thing for anyone, and if it only shows up when using |
Nemo157
referenced this issue
Oct 8, 2018
Open
Features of dependencies are enabled if they're enabled in build-dependencies; breaks no_std libs #5730
oconnor663
referenced this issue
Oct 10, 2018
Open
use a proper Cargo workspace, once feature selection bugs are fixed #18
added a commit
to azriel91/amethyst
that referenced
this issue
Oct 20, 2018
ehuss
referenced this issue
Oct 20, 2018
Open
Testing whole workspace with features enabled in some crate(s) #6195
added a commit
to azriel91/amethyst
that referenced
this issue
Oct 24, 2018
ehuss
added
the
A-features
label
Nov 18, 2018
This comment has been minimized.
This comment has been minimized.
arcnmx
commented
Dec 24, 2018
|
Okay it's incredibly frustrating that combining It's frustrating to see that there was a fix made and then suddenly reverted, with no other mitigation or progress since. This seems to be a pretty obvious footgun where most cases seem to be people using
Relying on obviously broken and weird behaviour, considering it to be a workaround in build scripts, not using other workarounds that rely on more established reasonable behaviour (like changing CWD rather than using -p/--all), and never expecting it to be fixed seems kind of unreasonable? There are solutions that could be employed to cause less breakage or even be partially or fully compatible with the old behaviour, but it seems unclear from this issue and the surrounding discussion why or how the old behaviour was relied on in the first place. |
This comment has been minimized.
This comment has been minimized.
|
@arcnmx breaking changes, whether they're fixing bugs or not, take care when approaching. We can't apply this change and then say "y'all deal with the fallout, it's a change for the better anyway". Our policy is that we would slowly roll out this change, providing warnings and such along the way. For example we would need to:
This takes a lot of work and no one has been sufficiently motivated to drive it to completion. |
This comment has been minimized.
This comment has been minimized.
|
Apologies if this has already been covered upthread, but would it be possible to make this change for virtual workspaces specifically? In that case, there is no current package, so it seems less likely to break the world. |
This comment has been minimized.
This comment has been minimized.
arcnmx
commented
Jan 4, 2019
|
Yeah, my intention is to revive the discussion here and determine what intermediate steps and migration plans are possible, it's just quite frustrating that the proper behaviour is inaccessbily stuck gated behind an unstable/nightly flag. My main points of concern are:
|
This comment has been minimized.
This comment has been minimized.
|
Perhaps switching the defaults (i.e hard fail rather than just warn) could also have an "opt-back" option (mentioned in the error message) for builds that need a second before migrating. Then we can drop the opt-back option. |
This comment has been minimized.
This comment has been minimized.
|
Given the fallout we previously experienced I'd be wary of changing this even for virtual workspaces myself. I'd personally prefer that we take a conservative route of "warn if things are different, allow configuration for new, 'correct', behavior" |
This comment has been minimized.
This comment has been minimized.
ririsoft
commented
Jan 14, 2019
|
Hi, basic developer using rust and getting into this issue here. I agree with the proposal to change the behavior and I understand the concerns regarding stability of the current yet buggy behavior.
This proposal would be perfectly fine for me: When doing Cheers. |
This comment has been minimized.
This comment has been minimized.
dhardy
commented
Jan 14, 2019
|
Alternative solution: deprecate the We already have another way of testing sub-packages:
|
This comment has been minimized.
This comment has been minimized.
cbeck88
commented
Jan 23, 2019
|
@dhardy Thanks very much for pointing out this effective and non-obvious workaround for this issue! |
This comment has been minimized.
This comment has been minimized.
|
Because of #5932 that workaround won't work in all cases, but it should work for any workspace that doesn't use |
matklad commentedApr 16, 2018
A tracking issue for #5353 and #5351. Historically,
--featureand related flags applied to the current package, and not to the package, specified via--package. This is a bug, but fixing it could break someone's code, so currently new behavior exists under-Z package-featuresopt-in. We need to check if it breaks code in the wild to see what we should do next.