cargo-component icon indicating copy to clipboard operation
cargo-component copied to clipboard

Error message for not selecting a component should be more actionable

Open lu4p opened this issue 1 year ago • 0 comments

I had this .wit file:

package example:adder;

interface add {
    add: func(a: u32, b: u32) -> u32;
}

/// An example world for the component to target.
world adder {
    export add;
}

world another {
    export add;
}

I got this error, but wasn't sure what exactly it meant.

$ cargo component build --release                                                                                                                                
error: failed to create a target world for package `adder` (/home/luap/Code/add/Cargo.toml)

Caused by:
    0: failed to select the default world to use for local target `/home/luap/Code/add/wit`
    1: multiple worlds found in package `example:adder`: one must be explicitly chosen

The fix is to add a world, to [package.metadata.component] in cargo.toml in my case:

world="adder"

this should be clearly stated in the error message

lu4p avatar Feb 01 '24 13:02 lu4p