货物,工作空间和临时本地依赖

ada*_*ahn 5 gfx rust rust-cargo

我在一个货物工作区中有两个项目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
Run Code Online (Sandbox Code Playgroud)

现在,我希望货物在my_project构建期间使用gfx的本地副本:

  1. 第一种方法(Cargo.toml中的本地路径):我将所有gfx软件包的源都更改为两个项目的Cargo.tomls中的本地路径。\不幸的是,货物隐含地假设(这对我来说有点疯狂) “路径”所指向的依赖项是工作空间的一部分,但是工作空间成员必须位于文件系统中的工作空间根目录之下。因此它拒绝构建项目,抱怨gfx *是工作空间的一部分,但它不在工作空间根目录下。AFAIK,当前无法更改此隐式“一切都在工作区”行为。
  2. 第二种方法([替换]):这种方法导致与上述相同的行为。[replace]内部指定的路径也隐式添加到工作空间中。
  3. 第三种方法(覆盖本地路径):我在.cargo / config中的路径中添加了gfx。也有必要将我的.tomls中的gfx软件包的源从crate.io更改为git信息库,因为被覆盖的软件包中的版本和.toml中引用的版本必须匹配。这在稳定的锈蚀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.
    
    Run Code Online (Sandbox Code Playgroud)

    错误:

    error: failed to find lock source of gfx_core
    
    Run Code Online (Sandbox Code Playgroud)

    我在项目内的Cargo.toml中指向的gfx和存储库的本地副本是相同的,因此我不明白为什么会发出此警告。

    该错误已在每晚的rust中修复,因此我已经安装了该错误,最终能够使用本地gfx副本编译项目。

因此,经过一天相对艰苦的工作后,我有了一个解决方案,该解决方案仅在夜间运行,并承诺在功能发布中将不起作用。

我的问题:

  1. 应该怎么做?
  2. 如何摆脱这个警告?

ada*_*ahn 1

结束话题;此讨论解决了该问题: https ://github.com/rust-lang/cargo/issues/3192

现在,指向工作区目录外部的路径不会隐式包含在工作区中。此外,exclude工作区配置也很关键。