{"record":{"id":"6d1d897320ce1682","repo":"bevyengine/bevy","slug":"executable-schedule-has-not-been-built","errorCode":null,"errorMessage":"executable schedule has not been built","messagePattern":"executable schedule has not been built","errorType":"exception","errorClass":"ScheduleNotInitialized","httpStatus":null,"severity":"error","filePath":"crates/bevy_ecs/src/schedule/schedule.rs","lineNumber":1934,"sourceCode":"}\n\n/// An event triggered when a schedule is successfully built.\n///\n/// Note: When this event is triggered, the corresponding [`Schedule`] is not present in the world.\n/// So, observers will need to cache whatever data they need from this and access it later once the\n/// schedule is not running.\n#[derive(Event)]\npub struct ScheduleBuilt {\n    /// The schedule that was built.\n    pub label: InternedScheduleLabel,\n    /// The metadata for the build process of this schedule.\n    pub build_metadata: ScheduleBuildMetadata,\n}\n\n/// Error to denote that [`Schedule::initialize`] or [`Schedule::run`] has not yet been called for\n/// this schedule.\n#[derive(Error, Debug)]\n#[error(\"executable schedule has not been built\")]\npub struct ScheduleNotInitialized;\n\n#[cfg(test)]\nmod tests {\n    use alloc::{vec, vec::Vec};\n    use core::any::TypeId;\n\n    use bevy_ecs_macros::ScheduleLabel;\n\n    use crate::{\n        error::{ignore, panic, FallbackErrorHandler, Result},\n        prelude::{ApplyDeferred, IntoSystemSet, Res, Resource},\n        schedule::{\n            passes::AutoInsertApplyDeferredPass, tests::ResMut, FlattenedDependencies,\n            IntoScheduleConfigs, MultiThreadedExecutor, Schedule, ScheduleBuildPass,\n            ScheduleBuildSettings, ScheduleCleanupPolicy, SystemSet,\n        },\n        system::Commands,","sourceCodeStart":1916,"sourceCodeEnd":1952,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_ecs/src/schedule/schedule.rs#L1916-L1952","documentation":"Returned (as an Err, not a panic) by Schedule::systems() and Schedule::systems_with_access() when the executable schedule has not been built yet - Schedule::initialize or Schedule::run has never been called for this schedule. These accessors read the built executable, so they require one initialization pass first.","triggerScenarios":"Calling schedule.systems() on a freshly constructed or freshly modified Schedule before initialize()/run(); inspector or stepping tooling enumerating systems of a schedule that has never executed.","commonSituations":"Editor/debug UIs listing systems at startup before the first frame; tests inspecting a newly assembled schedule without running it; code that assumes systems are enumerable immediately after add_systems.","solutions":["Call schedule.initialize(&mut world) (or one schedule.run(&mut world)) before iterating systems.","Defer inspection until after the first frame - e.g. react to the ScheduleBuilt event that fires when the schedule is built.","Propagate the Result instead of unwrapping so callers can retry later."],"exampleFix":"// before\nfor (key, system) in schedule.systems().unwrap() { /* Err(ScheduleNotInitialized) */ }\n\n// after\nschedule.initialize(&mut world)?;\nfor (key, system) in schedule.systems()? { /* ... */ }","handlingStrategy":"retry","validationCode":"// Ensure the executable exists before reading system info\nschedule.initialize(&mut world)?;\nlet systems = schedule.systems()?; // Ok now","typeGuard":null,"tryCatchPattern":"match schedule.systems() {\n    Ok(systems) => { /* iterate */ }\n    Err(ScheduleNotInitialized) => {\n        let _ = schedule.initialize(&mut world);\n        // retry next frame / after initialization\n    }\n}","preventionTips":["Treat initialize() as a precondition of every schedule inspection API.","Drive inspectors from the ScheduleBuilt event rather than polling before first run.","In tests, run one update before asserting on schedule contents."],"tags":["bevy","ecs","schedule","initialization","api-misuse"],"backgroundTag":"uninitialized-resource-access","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}