21

I searched for [rust] "instead of a package manifest" on this site before asking and found no hits. I also read about virtual manifests here but did not resolve my question.

My goal is to make changes to azul.

To achieve this I read about patching dependencies here, and now I have this 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" }

In path ../azul I have checked out the azul project with git clone. In main.rs I have followed this to get,

extern crate azul;

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

Then I try to test

$ 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

I do not understand the final caused by line. If I remove the [patch] configuration, it "works". Quoting because it fails to compile, but that is why I am trying to check it out and attempt a fix. What charges do I need to make to develop the azul dependency?

TIA,

Charles
  • 953
  • 1
  • 8
  • 19

2 Answers2

17

looks like azul is using workspaces so if you want to refer to it via path you must point to the exact member(s) of that workspace.

azul's Cargo.toml contains


[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",
]

so I believe you should be able to do something like:


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

you may need all/some of the members there.

user2987504
  • 547
  • 1
  • 5
  • 12
2

For those who come to this question because they tried cargo install and got the error message:

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

The solution is as simple as adding --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

For a workspace structured like this:

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

This is tracked in https://github.com/rust-lang/cargo/issues/7599

Cornelius Roemer
  • 3,772
  • 1
  • 24
  • 55