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

Cargo uses wrong dep version when dep is declared in [workspace.dependencies] #9682

Closed
f32by opened this issue Jul 12, 2021 · 3 comments
Closed
Labels
C-bug Category: bug

Comments

@f32by
Copy link

f32by commented Jul 12, 2021

Problem

Steps
Workspace's Cargo.toml:

[workspace.dependencies]
arrayvec = { version = "0.7", features = ["serde"] }

Workspace member's Cargo.toml:

[dependencies]
arrayvec = { workspace = true }
  1. Remove git and registry in ~/.cargo to force cargo re-download all deps.
  2. Run cargo build
  3. The member crate uses arrayvec-0.4.12 rather than arrayvec-0.7.1

Possible Solution(s)

Notes

Output of cargo version: cargo 1.55.0-nightly (3ebb5f1 2021-07-02)

@f32by f32by added the C-bug Category: bug label Jul 12, 2021
@ehuss
Copy link
Contributor

ehuss commented Jul 12, 2021

The ability to use workspace dependencies hasn't been implemented (see #8415). cargo build should print out several warnings to indicate that there are unrecognized fields:

warning: /ws/Cargo.toml: unused manifest key: workspace.dependencies
warning: /ws/foo/Cargo.toml: dependency (arrayvec) specified without providing a local path, Git repository, or version to use. This will be considered an error in future versions
warning: /ws/foo/Cargo.toml: unused manifest key: dependencies.arrayvec.workspace

When a dependency does not have a version, git, or path, Cargo treats it as version="*". As the warning mentions, this will be an error in the future.

Did those warnings not show up?

@f32by
Copy link
Author

f32by commented Jul 13, 2021

They did show up but I ignored them :( Thank you for clarification.

@ehuss
Copy link
Contributor

ehuss commented Jul 13, 2021

Ok, I'm going to close as this is generally working as expected. I imagine the warning could become an error, as it has been around for 6 years.

@ehuss ehuss closed this as completed Jul 13, 2021
bors added a commit that referenced this issue Jul 14, 2021
When a dependency does not have a version, git or path, fails directly

Make this warning be an error.

ref: #9682 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants