bevyengine/bevy · error

Error adding plugin : : plugin was already added in…

Error message

Error adding plugin {plugin_name}: : plugin was already added in application

What it means

Panics in the Plugins::add_to_app implementation for a single Plugin when App::add_boxed_plugin returns AppError::DuplicatePlugin: the exact plugin type has already been added to this App before. Bevy refuses to add the same plugin type twice to keep build logic idempotent.

Solutions

  1. Remove the duplicate app.add_plugin(...) / app.add_plugins(...) call for the same plugin type
  2. Check whether the plugin is already included via a PluginGroup (e.g. DefaultPlugins) before adding it manually
  3. If conditional, guard the addition with a check of the plugin registry or use feature gates to avoid double registration
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/bevy_app/src/plugin.rs:150 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20). Data as JSON: /api/errors/aeb31434e613b37b. Report an issue: GitHub.

Appendix: source

Thrown at crates/bevy_app/src/plugin.rs:150

    use variadics_please::all_tuples;

    use crate::{App, AppError, Plugin, PluginGroup};

    pub trait Plugins<Marker> {
        fn add_to_app(self, app: &mut App);
    }

    pub struct PluginMarker;
    pub struct PluginGroupMarker;
    pub struct PluginsTupleMarker;

    impl<P: Plugin> Plugins<PluginMarker> for P {
        #[track_caller]
        fn add_to_app(self, app: &mut App) {
            if let Err(AppError::DuplicatePlugin { plugin_name }) =
                app.add_boxed_plugin(Box::new(self))
            {
                panic!(
                    "Error adding plugin {plugin_name}: : plugin was already added in application"
                )
            }
        }
    }

    impl<P: PluginGroup> Plugins<PluginGroupMarker> for P {
        #[track_caller]
        fn add_to_app(self, app: &mut App) {
            self.build().finish(app);
        }
    }

    macro_rules! impl_plugins_tuples {
        ($(#[$meta:meta])* $(($param: ident, $plugins: ident)),*) => {
            $(#[$meta])*
            impl<$($param, $plugins),*> Plugins<(PluginsTupleMarker, $($param,)*)> for ($($plugins,)*)
            where

View on GitHub (pinned to 396ca72708)