Open ghost opened 5 years ago
Your real use case may be something more complex, but in the case of some
, you can delete the dev-dependency
entirely, and things will still work.
@sfackler Thanks I understand. In my project, some
belongs to an optional feature. That's why I need [dev-dependencies]
section.
hmm interesting
ran into this warning when trying to use tokio
there's no point to enable tokio test-util in prod so it made sense to just put tokio = {features=["test-util"]}
in dev-dependencies and let it add onto prod features but that brings up this warning.
[dependencies]
tokio = {version = "1.23.0", features = ["..."]}
[dev-dependencies]
tokio = {features = ["test-util"]}
With workspace inheritance you can do
[workspace.dependencies]
tokio = "1.23.0"
[dependencies]
tokio = {workspace = true, features = ["..."]}
[dev-dependencies]
tokio = {workspace = true, features = ["test-util"]}
On a somewhat related note, rust-lang/rfcs#3516 proposes a syntax for getting a version from one of your dependencies.
$ cargo add tokio
$ # Many moons later
$ cargo add tokio --dev -F test-util
cargo add
will fill in the dev-dependencies
version requirement based on the dependencies
entry.
I wonder how often people run into this problem for us to consider the upfront work and continued maintenance to support this.
Note: it looks like tokio = {features = ["test-util"]}
is treated as tokio = {version = "*", features = ["test-util"]}
and can be used besides these scenarios. Changing behavior here would technically be a breaking change. We'd likely want to make this a hard error before even considering adding it back in for some cases.
Hello Rust developers,
My Problem
In
Cargo.toml
, in order to use same version of a dependency for both[dependencies]
and[dev-dependencies]
, I use a reference:It compiles, but with a warning: dependency (some) specified without providing a local path, Git repository, or version to use. This will be considered an error in future versions.
Possible Solution(s)
Both section can declare their own version strings, and the warning will be gone. However, I'm using references to reduces mistakes, maintenance cost... Yes it is just a small version string, but I wish to be able to declare it in one single place.
Beside, references are legal: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html -- May I ask if you could make my problem above a legal declaration?
Notes
Output of
cargo version
:cargo 1.35.0 (6f3e9c367 2019-04-04)
Thank you,