{"record":{"id":"d7579c33a08b61c4","repo":"bevyengine/bevy","slug":"crossdependency","errorCode":"CrossDependency","errorMessage":"`{:?}` and `{:?}` have both `in_set` and `before`-`after` relationships (these might be transitive). This combination is unsolvable as a system cannot run before or after a set it belongs to.","messagePattern":"`(.+?)` and `(.+?)` have both `in_set` and `before`-`after` relationships \\(these might be transitive\\)\\. This combination is unsolvable as a system cannot run before or after a set it belongs to\\.","errorType":"error_code","errorClass":"ScheduleBuildError","httpStatus":null,"severity":"error","filePath":"crates/bevy_ecs/src/schedule/error.rs","lineNumber":33,"sourceCode":"    },\n    world::World,\n};\n\n/// Category of errors encountered during [`Schedule::initialize`](crate::schedule::Schedule::initialize).\n#[non_exhaustive]\n#[derive(Error, Debug)]\npub enum ScheduleBuildError {\n    /// Tried to topologically sort the hierarchy of system sets.\n    #[error(\"Failed to topologically sort the hierarchy of system sets: {0}\")]\n    HierarchySort(DiGraphToposortError<NodeId>),\n    /// Tried to topologically sort the dependency graph.\n    #[error(\"Failed to topologically sort the dependency graph: {0}\")]\n    DependencySort(DiGraphToposortError<NodeId>),\n    /// Tried to topologically sort the flattened dependency graph.\n    #[error(\"Failed to topologically sort the flattened dependency graph: {0}\")]\n    FlatDependencySort(DiGraphToposortError<SystemKey>),\n    /// Tried to order a system (set) relative to a system set it belongs to.\n    #[error(\"`{:?}` and `{:?}` have both `in_set` and `before`-`after` relationships (these might be transitive). This combination is unsolvable as a system cannot run before or after a set it belongs to.\", .0.0, .0.1)]\n    CrossDependency(#[from] DagCrossDependencyError<NodeId>),\n    /// Tried to order system sets that share systems.\n    #[error(\"`{:?}` and `{:?}` have a `before`-`after` relationship (which may be transitive) but share systems.\", .0.0, .0.1)]\n    SetsHaveOrderButIntersect(#[from] DagOverlappingGroupError<SystemSetKey>),\n    /// Tried to order a system (set) relative to all instances of some system function.\n    #[error(transparent)]\n    SystemTypeSetAmbiguity(#[from] SystemTypeSetAmbiguityError),\n    /// Tried to run a schedule before all of its systems have been initialized.\n    #[error(\"Tried to run a schedule before all of its systems have been initialized.\")]\n    Uninitialized,\n    /// A warning that was elevated to an error.\n    #[error(transparent)]\n    Elevated(#[from] ScheduleBuildWarning),\n}\n\n/// Category of warnings encountered during [`Schedule::initialize`](crate::schedule::Schedule::initialize).\n#[non_exhaustive]\n#[derive(Error, Debug)]","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_ecs/src/schedule/error.rs#L15-L51","documentation":"`CrossDependency` means a node (system or set) has both an `in_set` relationship and a `before`/`after` relationship with the same set, possibly transitively. A system cannot be ordered strictly before or after a set it belongs to — every member ordering includes itself — so the constraint set is unsolvable and schedule initialization fails.","triggerScenarios":"`.add_systems(s, my_system.in_set(MySet).before(MySet))`; or configuring `A.before(B)` where B contains A through a chain of `in_set` edges added by different plugins; run-conditions tuples that implicitly nest sets.","commonSituations":"Trying to pin one member of a set relative to the whole set ('run this cleanup after everything in Simulation'); plugin A ordering against plugin B's set while also adding its systems into that set; transitive containment making an apparently-legal ordering illegal.","solutions":["Order against a sibling instead of an enclosing set: point `.before`/`.after` at the specific system or a sibling set, not one that contains the constrained node","If the member genuinely must bracket the set, split the set so the constrained member moves outside it","Audit combined in_set + before/after configuration, including edges contributed by multiple plugins transitively"],"exampleFix":"// before\napp.add_systems(Update, cleanup.in_set(SimSet).after(SimSet)); // cross-dependency\n\n// after\napp.add_systems(Update, cleanup.after(sim_tick).after(sim_apply)); // order against members\n// or move cleanup out of SimSet","handlingStrategy":"try-catch","validationCode":"// Before configuring, keep an explicit model of set membership and check:\n// never order a node against a set that (transitively) contains it\nfn contains(hierarchy: &SetHierarchy, set: SetId, maybe_descendant: SetId) -> bool { /* walk edges */ false }","typeGuard":null,"tryCatchPattern":"match schedule.initialize(&mut world) {\n    Err(ScheduleBuildError::CrossDependency(DagCrossDependencyError(a, b))) => {\n        // a is both inside and ordered against b: repoint the ordering at a sibling\n    }\n    other => other.map(|_| ()),\n}","preventionTips":["Order within sets (member vs member), never member vs containing set","When two plugins must interleave, order their sibling sets rather than nesting plus ordering","Review every .before/.after against the in_set lattice after plugin merges"],"tags":["bevy","ecs","schedule","ordering","system-sets"],"backgroundTag":"circular-ordering-constraint","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}