Failed to parse manifest - Virtual manifests must be configured with [workspace]
Asked Answered
S

1

7

I'm running this in powershell for my Rust project:

cargo build --target thumbv7em-none-eabihf

And it produces this error after I try to execute this command:

error: failed to parse manifest at C:\Users\PC\Downloads\Blizzard\Cargo.toml Caused by: virtual manifests must be configured with [workspace]

Here is my Cargo.toml file:

[package]
name = "my-project"
version = "0.1.0"
authors = ["runner"]
edition = "2021"

[profile.dev]
panic = "abort"

[profile.release]
panic = "abort"

If it's needed, here is my rust file:

#![no_std]
#![no_main]

use core::panic::PanicInfo;

#[no_mangle]
pub extern "C" fn _start() -> ! {
    loop {}
}

#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
    loop {}
}

And my file path looks like this:

> Blizzard
  > src
   > main.rs
  > Cargo.toml

How can I fix this issue? Any help is appreciated

Shealy answered 30/3, 2022 at 0:31 Comment(8)
I googled and found this post, perhaps it will be helpful?Grandmother
@SteveLau will i need to add the bin/lib part from that solution for it to work?Shealy
Honestly I haven't encontered this error before, so I don't know what to do, sorry:(. This is the official doc for virtual manifest. However, according to the statement from this doc, I don't see any problems in your Cargo.tomlGrandmother
What directory are you in when you run cargo build?Sprat
I tried duplicating your folder structure and pasting your code, and the project compiled without problem (with cargo v1.59.0 on a Linux host).Umbrian
@KevinReid C:\Users\PC\Downloads\Blizzard> cargo build --target thumbv7em-none-eabihfShealy
I ran into the same thing. All I had to do was delete my Cargo.lock, make sure my Cargo.toml file was saved, and reran "cargo build" and my problem was solved. I didn't want to put this as an answer because not sure if this will work for your situation. Good luck!Leverrier
Had the same error. For me it was caused by an empty Cargo.toml file in the parent folder (the path reported was to there, not my work folder). Removing the file cleared the error.Herbalist
K
0

Add following in your cargo.toml

[workspace]
members = ["NameOfYourPackage"]
Kab answered 13/7 at 14:30 Comment(1)
Is this based on an actual experiment? Because, as said in the comments, the error generally should not happen and therefore this is not a solution.Eponymy

© 2022 - 2024 — McMap. All rights reserved.