{"record":{"id":"47c5b0a8e00a8382","repo":"bevyengine/bevy","slug":"the-resource-has-never-been-initialized-or-registe","errorCode":null,"errorMessage":"The resource has never been initialized or registered with the world. Did you forget to add it using `app.insert_resource` / `app.init_resource`?","messagePattern":"The resource has never been initialized or registered with the world\\. Did you forget to add it using `app\\.insert_resource` / `app\\.init_resource`\\?","errorType":"exception","errorClass":"ResourceFetchError::NotRegistered","httpStatus":null,"severity":"error","filePath":"crates/bevy_ecs/src/world/error.rs","lineNumber":68,"sourceCode":"#[derive(thiserror::Error, Debug, Clone, Copy, PartialEq, Eq)]\npub enum EntityMutableFetchError {\n    /// The entity is not spawned.\n    #[error(\n        \"{0}\\n\n    If you were attempting to apply a command to this entity,\n    and want to handle this error gracefully, consider using `EntityCommands::queue_handled` or `queue_silenced`.\"\n    )]\n    NotSpawned(#[from] EntityNotSpawnedError),\n    /// The entity with the given ID was requested mutably more than once.\n    #[error(\"The entity with ID {0} was requested mutably more than once\")]\n    AliasedMutability(Entity),\n}\n\n/// An error that occurs when getting a resource of a given type in a world.\n#[derive(thiserror::Error, Debug, Clone, Copy, PartialEq, Eq)]\npub enum ResourceFetchError {\n    /// The resource has never been initialized or registered with the world.\n    #[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`?\")]\n    NotRegistered,\n    /// The resource with the given [`ComponentId`] does not currently exist in the world.\n    #[error(\"The resource with ID {0:?} does not currently exist in the world.\")]\n    DoesNotExist(ComponentId),\n    /// Cannot get access to the resource with the given [`ComponentId`] in the world as it conflicts with an on going operation.\n    #[error(\"Cannot get access to the resource with ID {0:?} in the world as it conflicts with an on going operation.\")]\n    NoResourceAccess(ComponentId),\n    /// Tried to mutably fetch an immutable resource.\n    #[error(\"Tried to mutably fetch resource with ID {0:?}, which is immutable\")]\n    Immutable(ComponentId),\n}\n\n#[cfg(test)]\nmod tests {\n    use crate::{\n        prelude::*,\n        system::{command::trigger, RunSystemOnce},\n    };","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_ecs/src/world/error.rs#L50-L86","documentation":"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.","triggerScenarios":"Thrown at crates/bevy_ecs/src/world/error.rs:68 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}