30

I'm trying to build a Rust project (xray). When running cargo run I get the following error message

error: manifest path D:\xray\building\xray\Cargo.toml is a virtual manifest, but this command requires running against an actual package in this workspace

What exactly does this mean and how can it be solved? I'm using Cargo version 0.25.0 and Rust version 1.24.1.

Clemens Tolboom
  • 1,872
  • 18
  • 30
Amani
  • 16,245
  • 29
  • 103
  • 153

2 Answers2

31

Your Cargo.toml is a virtual manifest.

In workspace manifests, if the package table is present, the workspace root crate will be treated as a normal package, as well as a workspace. If the package table is not present in a workspace manifest, it is called a virtual manifest.

When working with virtual manifests, package-related cargo commands, like cargo build, won't be available anymore. But, most of such commands support the --all option, will execute the command for all the non-virtual manifest in the workspace.

cargo run does not work, because cargo doesn't know what to run. There are two options:

  1. --manifest-path <PATH>: Path to Cargo.toml of the crate you want to run.
  2. -p, --package <SPEC>: Package you want to run.

In your case it's probably cargo run --package xray_cli

Community
  • 1
  • 1
Tim Diekmann
  • 7,755
  • 11
  • 41
  • 69
  • This is exactly what I needed. I have an examples folder of local libraries that are each sub folders and their own Cargo.toml files. This worked great. – james-see Jul 28 '18 at 00:27
-3

the manifest has both package and workspace sections can't works. please check the Cargo.toml and remove package from it.

Virtual Manifest is new concepts, please reading docs to familiar it. Hope it values for you.

xds2000
  • 1,221
  • 13
  • 17