[英]How do I depend on a crate within a Cargo workspace over git?
Given a Cargo workspace in one git repository that contains one crate foo
, and another crate bar
outside of that workspace, how do I depend on foo
in bar
?给定一个 git 存储库中的Cargo 工作区,其中包含一个 crate
foo
,以及该工作区之外的另一个 crate bar
,我如何依赖foo
in bar
? If foo
were just a regular crate-within-a-git-repo, the following works:如果
foo
只是一个普通的 crate-within-a-git-repo,则以下工作:
foo = { git = "ssh://git@server/some/foo.git", ... }
And if foo
were inside a Cargo workspace and it lives in a local directory, the following works:如果
foo
在 Cargo 工作区中并且它位于本地目录中,则以下工作:
foo = { path = "../../some-workspace/foo" }
But using git = "ssh://..."
that points to a repository that contains a Cargo workspace, I am unable to specify the foo
crate in particular.但是使用指向包含 Cargo 工作区的存储库的
git = "ssh://..."
,我无法特别指定foo
板条箱。
It is not possible to combine git = "..."
and path = "..."
, since those are mutually exclusive.不能组合
git = "..."
和path = "..."
,因为它们是互斥的。
In the Specifying dependencies from git repositories chapter of The Cargo Book, it offers branch = "..."
, tag = "..."
, rev = "..."
, but no "sub-crate's directory name, ie the name of the crate".在 The Cargo Book 的从 git 存储库中指定依赖项一章中,它提供了
branch = "..."
, tag = "..."
, rev = "..."
,但没有“子箱的目录名称,即箱子的名称”。 There is a package = "..."
specifier mentioned under Renaming dependencies in Cargo.toml meant for importing a crate as something else.在 Cargo.toml 的重命名依赖项下提到了
package = "..."
说明符,用于将板条箱作为其他东西导入。 But it doesn't seem to double as the crate-within-a-workspace specifier.但它似乎并不能兼作 crate-within-a-workspace 说明符。
Your dependency name should have the name of the crate in the workspace.您的依赖项名称应该具有工作区中 crate 的名称。 Cargo will search for it.
货物会搜索它。 Suppose the workspace foo has crate bar within it.
假设工作区 foo 里面有 crate bar。
bar = { git = "ssh://git@server/some/foo.git", ... }
Not sure where this is documented, but there is a discussion here:不知道这是在哪里记录的,但这里有一个讨论:
https://github.com/rust-lang/cargo/issues/10151 https://github.com/rust-lang/cargo/issues/10151
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.