在路径 <path> 找到了一个虚拟清单而不是一个包清单。

23

在发问之前,我在这个网站上搜索了[rust] "instead of a package manifest",但没有找到任何结果。我还在这里读到有关虚拟清单的内容,但是没有解决我的问题。

我的目标是对azul进行更改。

为了实现这一点,我阅读了这里关于修补依赖的内容,现在我有了这个Cargo.toml文件。

[package]
name = "my_first_azul_app"
version = "0.1.0"
authors = ["Name <Email>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
azul = { git = "https://github.com/maps4print/azul" }

[patch."https://github.com/maps4print/azul"]
azul = { path = "../azul" }

在路径 ../azul 中,我使用 git clone 检出了 azul 项目。在 main.rs 文件中,我按照这里的说明进行操作,获取了以下内容:

extern crate azul;

fn main() {
    println!("Hello world!");
}

然后我尝试进行测试

$ cargo run
error: failed to resolve patches for `https://github.com/maps4print/azul`

Caused by:
  failed to load source for a dependency on `azul`

Caused by:
  Unable to update /home/name/projects/azul

Caused by:
  found a virtual manifest at `/home/name/projects/azul/Cargo.toml` instead of a package manifest

我不理解由哪一行引起的最终结果。 如果我删除[patch]配置,它就可以“正常工作”。 引用它无法编译,但这就是我尝试检查它并尝试修复它的原因。我需要做什么修改才能开发azul依赖项?

TIA,

2个回答

18

看起来Azul正在使用工作区,因此如果您想通过路径引用它,则必须指向该工作区的确切成员。

Azul的Cargo.toml包含


[workspace]
members = [
    "cargo/azul",
    "cargo/azul-css",
    "cargo/azul-core",
    "cargo/azul-layout",
    "cargo/azul-text-layout",
    "cargo/azul-widgets",
    "cargo/azul-css-parser",
    "cargo/azul-native-style",
]

所以我认为你应该能够做类似这样的事情:


[dependencies]
azul = { path = "../azul/cargo/azul"
azul-css = { path = "../azul/cargo/azul-css" }

你可能需要所有/其中一些成员在那里。


4

对于那些因为尝试了cargo install而收到错误信息的人:

$ cargo install                            
error: found a virtual manifest at `~/nextclade/Cargo.toml` instead of a package manifest

解决方案就是添加 --path <executable-sub-cratepath>

$ cargo install --path packages_rs/nextclade-cli                         
error: found a virtual manifest at `~/nextclade/Cargo.toml` instead of a package manifest

对于这样结构化的工作空间:

.
├── Cargo.toml
└── packages_rs
   ├── nextclade
      └── Cargo.toml
   ├── nextclade-cli
      └── Cargo.toml
   └── nextclade-web
      └── Cargo.toml

这个问题已经在https://github.com/rust-lang/cargo/issues/7599中被跟踪。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接