-
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
Workspace dependencies getting rebuilt when child dependency versions differ #3151
Comments
After a bit more investigating, it appears that the true culprit is a difference in the features in one of the dependencies. Building child_one:
Building root:
|
Ah yeah differences in features would do it. #3102 would help here in that regard, but the other fix would be to ensure that no matter what crate is being compiled the activated feature set is the same. |
Is there any workaround for right now? I've read a little about the |
The "workaround" for now is to just ensure that your top-level targets build the same set of features into each dependency (e.g. in this case activating the |
Ah, I see. Didn't realize that I could add net2 as a dependency of my crate, muck with its features, and have that take precedence over the one that mio pulled in. Seems to be working! 👍 |
We have also hit this with Iron and Hyper, where Iron defines a different feature set, so whenever hyper is used in a crate without Iron we also need to set the same feature set. This is a bit of a pain to do and would be better if either the union of the features required was produced, or if the library targets included the features used in the name. |
Ok, #3102 has landed, so I believe this is fixed. @Pursuit92 can you confirm? |
Looks like it's still a problem - #3102 did indeed fix the recompilation of the transitive net2 dependency, but now the crates that depend on it are still getting rebuilt.
My guess is that this is because the changes from #3102 need to cascade up the dependency chain. Cargo is only resolving one version of miow which depends on different versions of net2 in different contexts where it should resolve different versions of it for each dependency configuration. Your other suggested fix (ensuring that the activated features are the same, regardless of where you build from) seems like it might be a cleaner and less build-directory-bloaty option. On the other hand, couldn't the single feature set approach introduce subtle bugs in dependencies if a differing activated feature set than they're expecting causes problems? |
Ah yes, right! Once #3310 lands I'll work towards solving this issue as well. |
@Pursuit92 said:
Unfortunately it seems like conflicting feature sets are going to be a problem either way. I'd say the situation now is much more subtle than if the activated feature set was consistent across the workspace. Right now in my workspace +1 for consistent feature sets across the workspace. |
I think that #3923 is a duplicate of this issue, but I've written out what's going on there and in addition to #3151 (comment) above I think we've got the bases covered in terms of what's happening. I'm goign to close this in favor of #3923 just to deduplicate things. |
I have a project with a workspace top-level crate that encompasses a number of crates as path dependencies. Without code changes, I can run a build in one of the children, and then in the top crate, and back and forth, etc. and trigger rebuilds every time.
It appears to me that the cause of this is that two of the child crates depend on different versions of the same crate from crates.io, which for some reason is causing it to get rebuilt. My assumption for workspaces was that dependencies should be resolved and cached across all crates, even if there are different versions.
Minimal example project: https://github.com/Pursuit92/cargo_workspace_bug
The real project where I'm seeing the issue has the version discrepancy in the dependency of a dependency: https://github.com/catt-ha/catt-rs
Cargo version: cargo 0.13.0-nightly (19cfb67 2016-09-28)
Rustc version: rustc 1.14.0-nightly (86affcdf6 2016-09-28)
The text was updated successfully, but these errors were encountered: