Skip to content
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

Weird behavior when cargo add dep (workspace) to dependencies #14904

Closed
cxw620 opened this issue Dec 6, 2024 · 2 comments
Closed

Weird behavior when cargo add dep (workspace) to dependencies #14904

cxw620 opened this issue Dec 6, 2024 · 2 comments
Labels
C-bug Category: bug Command-add S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.

Comments

@cxw620
Copy link

cxw620 commented Dec 6, 2024

Problem

The workspace dependencies:
Image

The Cargo.lock
Image

However, when I run the command like cargo add --package my_package chrono --features std, cargo complains:

    Updating crates.io index
      Adding chrono (workspace) to dependencies
error: unrecognized feature for crate chrono: std
disabled features:
    rustc-serialize, serde

rustc-serialize, serde are actually the features of chrono@=0.4.0 instead of chrono@=0.4.38.

workspace.resolver is set to "3", edition 2024.

Steps

No response

Possible Solution(s)

No response

Notes

No response

Version


@cxw620 cxw620 added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Dec 6, 2024
@epage
Copy link
Contributor

epage commented Dec 6, 2024

Can you share your workspace.dependencies?

Most likely what is happening is your version requirement in workspace.dependencies is low enough to include a version with rustc-serialize and serde.

Dependencies specify a version requirement which includes support for a range of supported versions. To aid users in supporting the full range of their version requirement, cargo add only validates against and lists features for the lowest version within the range, making the assumption that features are not removed as that is a breaking change.

See also

@epage epage added S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. and removed S-triage Status: This issue is waiting on initial triage. labels Dec 6, 2024
@cxw620
Copy link
Author

cxw620 commented Dec 7, 2024

Can you share your workspace.dependencies?

chrono = { version = "0.4", default-features = false }.

Image

If I set to 0.4.38 instead of 0.4, it works well.

Image

According to your explanation in #14648, the oldest version compatible with 0.4 is 0.4.0...

Thank you for your reply and I will close the issue.

@cxw620 cxw620 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug Command-add S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.
Projects
None yet
Development

No branches or pull requests

2 participants