bevyengine/bevy · error

Cannot enable a plugin that does not exist.

Error message

Cannot enable a plugin that does not exist.

What it means

Panics in PluginGroupBuilder::enable because the plugins map has no entry for TypeId::of::<T>(): there is no plugin of type T in this group to re-enable. Enable is meant to opt back in after disable(), so the plugin must already be part of the group (even if disabled).

Source

Thrown at crates/bevy_app/src/plugin_group.rs:541

        };

        let target_index = target_index + 1;

        self.order.insert(target_index, TypeId::of::<Insert>());
        self.upsert_plugin_state(plugin, target_index);
        Ok(self)
    }

    /// Enables a [`Plugin`].
    ///
    /// [`Plugin`]s within a [`PluginGroup`] are enabled by default. This function is used to
    /// opt back in to a [`Plugin`] after [disabling](Self::disable) it. If there are no plugins
    /// of type `T` in this group, it will panic.
    pub fn enable<T: Plugin>(mut self) -> Self {
        let plugin_entry = self
            .plugins
            .get_mut(&TypeId::of::<T>())
            .expect("Cannot enable a plugin that does not exist.");
        plugin_entry.enabled = true;
        self
    }

    /// Disables a [`Plugin`], preventing it from being added to the [`App`] with the rest of the
    /// [`PluginGroup`]. The disabled [`Plugin`] keeps its place in the [`PluginGroup`], so it can
    /// still be used for ordering with [`add_before`](Self::add_before) or
    /// [`add_after`](Self::add_after), or it can be [re-enabled](Self::enable). If there are no
    /// plugins of type `T` in this group, it will panic.
    pub fn disable<T: Plugin>(mut self) -> Self {
        let plugin_entry = self
            .plugins
            .get_mut(&TypeId::of::<T>())
            .expect("Cannot disable a plugin that does not exist.");
        plugin_entry.enabled = false;
        self
    }

View on GitHub (pinned to 396ca72708)

Solutions

  1. Only call enable::<T>() for plugin types that were added to (and possibly disabled in) this PluginGroupBuilder
  2. Check spelling of the generic plugin type parameter
  3. If the plugin may not be in the group, use the non-panicking try-based equivalent if available, or restructure to add it first
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/bevy_app/src/plugin_group.rs:541 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/c311d29f18542a50. Report an issue: GitHub.