我可以发布一个使用补丁的 crate 吗?

Can I publish a crate that uses a patch?

Rust 文档中讨论 patching 的部分解释了如何实施补丁,但它使用的所有示例都用于“测试”和短期修复。我想做的是为我依赖的其中一个板条箱打一个补丁,它会增加它的子依赖性, 然后我想发布我的板条箱及其对 crates.io[ 的修补依赖项=22=]。但是,当您创建补丁时,您必须列出路径依赖性,如示例所示:

[patch.crates-io]
uuid = { path = "../path/to/uuid" }

我想这会阻止我发布我的箱子,因为我现在依赖于 crates.io 中没有的东西。

总的来说,我的问题是:我可以向 crates.io 发布一个使用本地补丁的 crate 吗?如果没有,是否有针对这种情况的其他解决方法?

It is not possible

Note: crates.io does not allow packages to be published with path dependencies (path dev-dependencies are ignored). See the Multiple locations section for a fallback alternative.

It is possible to specify both a registry version and a git or path location. The git or path dependency will be used locally (in which case the version is checked against the local copy), and when published to a registry like crates.io, it will use the registry version. Other combinations are not allowed.

您需要将依赖项上传到 crates.io。