Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] Create your first plugin example in documentation is not working #7630

Closed
SirMishaa opened this issue Feb 11, 2023 · 3 comments
Closed
Labels
C-Docs An addition or correction to our documentation C-Examples An addition or correction to our examples

Comments

@SirMishaa
Copy link

SirMishaa commented Feb 11, 2023

Hello, the part Create your first plugin in the documentation is not working. It looks like there is a PluginGroup trait that need to be implemented.

Can you update the documentation in accordance to avoid troubling new user?

use bevy::prelude::{App, Commands, Component, Plugin, Query, With};
use bevy::MinimalPlugins;

#[derive(Component)]
struct Person;

#[derive(Component)]
struct Name(String);

struct HelloPlugin;

impl Plugin for HelloPlugin {
    fn build(&self, app: &mut App) {
        app.add_startup_system(add_people).add_system(greet_people);
    }
}

fn main() {
    App::new()
        .add_plugins(MinimalPlugins)
        .add_plugins(HelloPlugin)
        .run()
}

fn greet_people(query: Query<&Name, With<Person>>) {
    for name in query.iter() {
        println!("hello {}!", name.0);
    }
}

fn add_people(mut commands: Commands) {
    commands.spawn((Person, Name("Elaina Proctor".to_string())));
    commands.spawn((Person, Name("Renzo Hume".to_string())));
    commands.spawn((Person, Name("Zayna Nieves".to_string())));
}

See the following error:

bevy-basic on  main [!+?] is  v0.1.0 via  v1.69.0-nightly on   (eu-central-1)
(❌ ~ 101) ❯ cargo run --color=always --package bevy-basic --bin bevy-basic
   Compiling bevy-basic v0.1.0 (/home/mishaa/dev/bevy-basic)
error[E0277]: the trait bound `HelloPlugin: PluginGroup` is not satisfied
   --> src/main.rs:21:22
    |
21  |         .add_plugins(HelloPlugin)
    |          ----------- ^^^^^^^^^^^ the trait `PluginGroup` is not implemented for `HelloPlugin`
    |          |
    |          required by a bound introduced by this call
    |
    = help: the following other types implement trait `PluginGroup`:
              DefaultPlugins
              MinimalPlugins
              NoopPluginGroup
              PluginGroupBuilder
note: required by a bound in `App::add_plugins`
   --> /home/mishaa/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_app-0.9.1/src/app.rs:928:27
    |
928 |     pub fn add_plugins<T: PluginGroup>(&mut self, group: T) -> &mut Self {
    |                           ^^^^^^^^^^^ required by this bound in `App::add_plugins`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `bevy-basic` due to previous error

Thanks! ❤️

@SirMishaa SirMishaa added C-Docs An addition or correction to our documentation S-Needs-Triage This issue needs to be labelled labels Feb 11, 2023
@alice-i-cecile alice-i-cecile added C-Examples An addition or correction to our examples and removed S-Needs-Triage This issue needs to be labelled labels Feb 11, 2023
@alice-i-cecile
Copy link
Member

.add_plugins(HelloPlugin)

Tiny but critical typo there :)

@SirMishaa
Copy link
Author

.add_plugins(HelloPlugin)

Tiny but critical typo there :)

Oh, I'm so sorry, my bad ! :(

I'm closing, this is working.

@alice-i-cecile
Copy link
Member

No worries, this is a bit of a footgun.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Docs An addition or correction to our documentation C-Examples An addition or correction to our examples
Projects
None yet
Development

No branches or pull requests

2 participants