簡體   English   中英

貨物,工作空間和臨時本地依賴

[英]Cargo, workspace and temporary local dependency

我在一個貨物工作區中有兩個項目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

現在,我希望貨物在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. 

    錯誤:

     error: failed to find lock source of gfx_core 

    我在項目內的Cargo.toml中指向的gfx和存儲庫的本地副本是相同的,因此我不明白為什么會發出此警告。

    該錯誤已在每晚的rust中修復,因此我已經安裝了該錯誤,最終能夠使用本地gfx副本編譯項目。

因此,經過一天相對艱苦的基本工作之后,我有了一個解決方案,該解決方案僅在夜間運行,並承諾在功能發布中將不起作用。

我的問題:

  1. 應該怎么做?
  2. 如何擺脫這個警告?

結束話題; 該討論解決了該問題: https : //github.com/rust-lang/cargo/issues/3192

現在,指向工作空間目錄外部的路徑不會隱式包含在工作空間中。 此外,工作空間配置中沒有exclude鍵。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM