bevyengine/bevy · error
Requested resource {} does not exist in the `World`.
Error message
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. What it means
Error "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." thrown in bevyengine/bevy.
Source
Thrown at crates/bevy_ecs/src/world/deferred_world.rs:466
&mut self,
state: &'s mut QueryState<D, F>,
) -> Query<'_, 's, D, F> {
// SAFETY: We have mutable access to the entire world
unsafe { state.query_unchecked(self.world) }
}
/// Gets a mutable reference to the resource of the given type
///
/// # Panics
///
/// Panics if the resource does not exist.
/// Use [`get_resource_mut`](DeferredWorld::get_resource_mut) instead if you want to handle this case.
#[inline]
#[track_caller]
pub fn resource_mut<R: Resource<Mutability = Mutable>>(&mut self) -> Mut<'_, R> {
match self.get_resource_mut() {
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 mutable reference to the resource of the given type if it exists
#[inline]
pub fn get_resource_mut<R: Resource<Mutability = Mutable>>(&mut self) -> Option<Mut<'_, R>> {
// SAFETY: &mut self ensure that there are no outstanding accesses to the resource
unsafe { self.world.get_resource_mut() }
}
/// Gets a mutable reference to the non-send data of the given type, if it exists.
///View on GitHub (pinned to 396ca72708)
Solutions
- Add the resource first: app.insert_resource(...) / app.init_resource::<R>()
- Use get_resource_mut().expect(...) or match on Option to control the failure yourself
- Use get_resource_or_insert_with to lazily create it
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at crates/bevy_ecs/src/world/deferred_world.rs:466 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/6dd727c0ab0e39dd.
Report an issue: GitHub.