我在一个货物工作区中有两个项目 my_project 和 my_inner_project。它们都依赖于 gfx(以及 gfx_core 和 gfx_device_gl)。我在 gfx_device_core 中发现了一个错误,所以我将它分叉、克隆、修补到本地,并希望在提交之前对其进行测试。
项目结构:
-my_project
--my_inner_project
---Cargo.toml
--Cargo.toml
-gfx
--src
---core
----Cargo.toml #package gfx_core
---backend
----gl
-----Cargo.toml #package gfx_device_gl
---render
----Cargo.toml #package gfx
--Cargo.toml
现在我希望 cargo 在 my_project 构建期间使用 gfx 的本地副本:
- 第一种方法(Cargo.toml 中的本地路径):我已将所有 gfx 包的源更改为我的两个项目的 Cargo.toml 中的本地路径。\不幸的是,cargo 隐含地假设(这对我来说有点疯狂),所有“路径”指向的依赖项是工作空间的一部分,但工作空间成员必须位于文件系统中的工作空间根目录之下。所以它拒绝构建项目,抱怨 gfx* 是工作区的一部分,但它不在工作区根目录下。AFAIK,目前没有办法改变这种隐含的“一切都在工作区”行为。
- 第二种方法([替换]):这种方法导致与上述相同的行为。[replace] 中指定的路径也被隐式添加到工作区中。
第三种方法(本地路径覆盖):我已将 gfx 添加到 .cargo/config 中的路径。还需要将我的 .toml 中的 gfx 包的源从 crate.io 更改为 git 存储库,因为覆盖包中的版本和 .toml 中引用的版本必须匹配。这也不适用于稳定的 rust 1.13。我收到警告:
warning: path override for crate `gfx_device_gl` has altered the original list of dependencies; the dependency on `gfx_core` was either added or modified to not match the previously resolved version This is currently allowed but is known to produce buggy behavior with spurious recompiles and changes to the crate graph. Path overrides unfortunately were never intended to support this feature, so for now this message is just a warning. In the future, however, this message will become a hard error. To change the dependency graph via an override it's recommended to use the `[replace]` feature of Cargo instead of the path override feature. This is documented online at the url below for more information.
和错误:
error: failed to find lock source of gfx_core
我的项目中 Cargo.toml 中指向的 gfx 和存储库的本地副本是相同的,所以我不明白为什么会发出此警告。
该错误在 rust nightly 中得到修复,所以我已经安装了它,最后能够使用我的本地 gfx 副本编译项目。
因此,在为相对基本的任务苦苦挣扎了一天之后,我有了一个解决方案,该解决方案仅适用于夜间,并且承诺它不会在功能发布中起作用。
我的问题:
- 应该怎么做?
- 如何摆脱这个警告?