Is it possible to publish crates with "path" specified?


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 with wildcard dependencies (*), git dependencies, path dependencies or dependencies from other registries. Read more about it in this section of the cargo book:


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 too.


Yes, good point. Multiple locations are documented in the cargo book here:

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, I must specify the paths to use my modified versions.

Have you tried multiple locations?

# Uses `my-bitflags` when used locally, and uses
# version 1.0 from 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 If someone were to download your package, it would be build with the bitflags v1.0 crate published on

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.