bevyengine/bevy · error

Requested resource {} does not exist in the `World`.\n

Error message

Requested resource {} does not exist in the `World`.\n                Did you forget to add it using `app.insert_resource` / `app.init_resource`?\n                Resources are also implicitly added via `app.add_message`,\n                and can be added by plugins.

What it means

Error "Requested resource {} does not exist in the `World`.\n Did you forget to add it using `app.insert_resource` / `app.init_resource`?\n Resources are also implicitly added via `app.add_message`,\n and can be added by plugins." thrown in bevyengine/bevy.

Source

Thrown at crates/bevy_ecs/src/world/mod.rs:2202

        let entity_ref = self.get_entity(entity).ok()?;
        entity_ref.get_change_ticks_by_id(component_id)
    }

    /// Gets a reference to the resource of the given type
    ///
    /// # Panics
    ///
    /// Panics if the resource does not exist.
    /// Use [`get_resource`](World::get_resource) instead if you want to handle this case.
    ///
    /// If you want to instead insert a value if the resource does not exist,
    /// use [`get_resource_or_insert_with`](World::get_resource_or_insert_with).
    #[inline]
    #[track_caller]
    pub fn resource<R: Resource>(&self) -> &R {
        match self.get_resource() {
            Some(x) => x,
            None => panic!(
                "Requested resource {} does not exist in the `World`.
                Did you forget to add it using `app.insert_resource` / `app.init_resource`?
                Resources are also implicitly added via `app.add_message`,
                and can be added by plugins.",
                DebugName::type_name::<R>()
            ),
        }
    }

    /// Gets a reference to the resource of the given type
    ///
    /// # Panics
    ///
    /// Panics if the resource does not exist.
    /// Use [`get_resource_ref`](World::get_resource_ref) instead if you want to handle this case.
    ///
    /// If you want to instead insert a value if the resource does not exist,
    /// use [`get_resource_or_insert_with`](World::get_resource_or_insert_with).

View on GitHub (pinned to 396ca72708)

Solutions

  1. Add the resource with app.insert_resource(...) / app.init_resource::<R>()
  2. Use world.get_resource::<R>() to handle absence gracefully
  3. Use get_resource_or_insert_with to lazily initialize it
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at crates/bevy_ecs/src/world/mod.rs:2202 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/544bd93c7ccc5e1a. Report an issue: GitHub.