Run
cargo publish --dry-run
It said:
the `path` specification will be removed from the dependency declaration
Run
cargo publish --dry-run
It said:
the `path` specification will be removed from the dependency declaration
No, it is not. You can't publish packages on crates.io with wildcard dependencies (*
), git dependencies, path dependencies or dependencies from other registries. Read more about it in this section of the cargo book:
https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html
What you can do is have both a version and a path specified. In local development the path is used, and in publication the path is deleted so that the dependency will be fetched from crates.io too.
Yes, good point. Multiple locations are documented in the cargo book here:
https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#multiple-locations
This is very useful for workspaces.
Some crates are licensed under MIT or Apache 2.0, so I can change their source code or configuration files. If I specify the versions, cargo will download it from crates.io, I must specify the paths to use my modified versions.
Have you tried multiple locations?
[dependencies]
# Uses `my-bitflags` when used locally, and uses
# version 1.0 from crates.io when published.
bitflags = { path = "my-bitflags", version = "1.0" }
This will cause your local project (on your computer) to use bitflags
from your local directory my-bitflags
but you can still publish your package to crates.io. If someone were to download your package, it would be build with the bitflags v1.0
crate published on crates.io.
If you intend to publish the crate depending on the modified versions, then these modified versions must be published too. Otherwise, how will the users of your crate get them?
Yes. That's precisely the reason to reject path
during publishing.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.