{"record":{"id":"9e8ef7bae2ad9bd3","repo":"bevyengine/bevy","slug":"error-when-initializing-schedule","errorCode":null,"errorMessage":"Error when initializing schedule {:?}: {}","messagePattern":"Error when initializing schedule (.+?): (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/bevy_ecs/src/schedule/schedule.rs","lineNumber":575,"sourceCode":"    }\n\n    /// Set whether the schedule applies deferred system buffers on final time or not. This is a catch-all\n    /// in case a system uses commands but was not explicitly ordered before an instance of\n    /// [`ApplyDeferred`]. By default this\n    /// setting is true, but may be disabled if needed.\n    pub fn set_apply_final_deferred(&mut self, apply_final_deferred: bool) -> &mut Self {\n        self.executor.set_apply_final_deferred(apply_final_deferred);\n        self\n    }\n\n    /// Runs all systems in this schedule on the `world`, using its current execution strategy.\n    pub fn run(&mut self, world: &mut World) {\n        #[cfg(feature = \"trace\")]\n        let _span = info_span!(\"schedule\", name = ?self.label).entered();\n\n        world.check_change_ticks();\n        self.initialize(world).unwrap_or_else(|e| {\n            panic!(\n                \"Error when initializing schedule {:?}: {}\",\n                self.label,\n                e.to_string(self.graph(), world)\n            )\n        });\n\n        let error_handler = world.fallback_error_handler();\n\n        #[cfg(not(feature = \"bevy_debug_stepping\"))]\n        self.executor\n            .run(&mut self.executable, world, None, error_handler);\n\n        #[cfg(feature = \"bevy_debug_stepping\")]\n        {\n            let skip_systems = match world.get_resource_mut::<Stepping>() {\n                None => None,\n                Some(mut stepping) => stepping.skipped_systems(self),\n            };","sourceCodeStart":557,"sourceCodeEnd":593,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_ecs/src/schedule/schedule.rs#L557-L593","documentation":"Schedule::run initializes the schedule before executing it; if building the executable schedule fails (ordering cycles, self-loops, ambiguous SystemTypeSet ordering, other build errors), run() panics with this wrapper message. The text after the colon embeds the underlying ScheduleBuildError rendered against the graph and world, naming the offending nodes/edges. It fires on the first run of the schedule, typically the first frame.","triggerScenarios":"Any ScheduleBuildError surfacing through Schedule::run: a cycle or self-loop introduced by new ordering constraints, ordering against a duplicated system type, or graph inconsistencies added since the last successful run.","commonSituations":"App panics on frame 1 after adding a plugin or ordering constraint; systems/sets configured differently between test and app so a constraint only loops in one of them; large refactors of schedule configuration.","solutions":["Read the embedded detail after the colon - it identifies the exact nodes and constraint at fault; fix that underlying build error.","Reproduce as a failing test: call app.update() once right after configuring systems so CI catches it before runtime.","If you need the error instead of a panic, call schedule.initialize(&mut world) yourself and handle the Result before calling run()."],"exampleFix":"// before\nschedule.run(&mut world); // panics on invalid graph\n\n// after\nif let Err(e) = schedule.initialize(&mut world) {\n    log::error!(\"bad schedule: {}\", e.to_string(schedule.graph(), world));\n    return;\n}\nschedule.run(&mut world);","handlingStrategy":"try-catch","validationCode":"// Fail fast in a test instead of frame 1\n#[test]\nfn app_boots() {\n    let mut app = App::new();\n    app.add_plugins(DefaultPlugins);\n    app.update();\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = schedule.initialize(&mut world) {\n    log::error!(\"schedule init failed: {}\", e.to_string(schedule.graph(), world));\n    return; // skip running instead of letting run() panic\n}\nschedule.run(&mut world);","preventionTips":["Run one app.update() in CI for every schedule composition you ship.","Centralize schedule configuration so constraints are auditable in one module.","Treat any new ordering constraint as requiring a smoke test."],"tags":["bevy","ecs","schedule","panic","initialization","build-error"],"backgroundTag":"configuration-validation-failed","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}