bevyengine/bevy · error · ResourceFetchError::NotRegistered
The resource has never been initialized or registered with t
Error message
The resource has never been initialized or registered with the world. Did you forget to add it using `app.insert_resource` / `app.init_resource`?
What it means
ResourceFetchError::NotRegistered: the requested resource type has never been initialized or registered in this world — its component id does not exist, so no amount of current-state checking will find it.
Source
Thrown at crates/bevy_ecs/src/world/error.rs:68
#[derive(thiserror::Error, Debug, Clone, Copy, PartialEq, Eq)]
pub enum EntityMutableFetchError {
/// The entity is not spawned.
#[error(
"{0}\n
If you were attempting to apply a command to this entity,
and want to handle this error gracefully, consider using `EntityCommands::queue_handled` or `queue_silenced`."
)]
NotSpawned(#[from] EntityNotSpawnedError),
/// The entity with the given ID was requested mutably more than once.
#[error("The entity with ID {0} was requested mutably more than once")]
AliasedMutability(Entity),
}
/// An error that occurs when getting a resource of a given type in a world.
#[derive(thiserror::Error, Debug, Clone, Copy, PartialEq, Eq)]
pub enum ResourceFetchError {
/// The resource has never been initialized or registered with the world.
#[error("The resource has never been initialized or registered with the world. Did you forget to add it using `app.insert_resource` / `app.init_resource`?")]
NotRegistered,
/// The resource with the given [`ComponentId`] does not currently exist in the world.
#[error("The resource with ID {0:?} does not currently exist in the world.")]
DoesNotExist(ComponentId),
/// Cannot get access to the resource with the given [`ComponentId`] in the world as it conflicts with an on going operation.
#[error("Cannot get access to the resource with ID {0:?} in the world as it conflicts with an on going operation.")]
NoResourceAccess(ComponentId),
/// Tried to mutably fetch an immutable resource.
#[error("Tried to mutably fetch resource with ID {0:?}, which is immutable")]
Immutable(ComponentId),
}
#[cfg(test)]
mod tests {
use crate::{
prelude::*,
system::{command::trigger, RunSystemOnce},
};View on GitHub (pinned to 396ca72708)
Solutions
- Call app.insert_resource(value) or app.init_resource::<R>() before fetching
- In tests, init the resource on the fixture world before running systems
- Match on ResourceFetchError to handle the missing case gracefully
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at crates/bevy_ecs/src/world/error.rs:68 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/47c5b0a8e00a8382.
Report an issue: GitHub.