bevyengine/bevy · error

Duplicate required components are not allowed.

Error message

Duplicate required components are not allowed.

What it means

Compile-time error from ComponentAttributes::parse: the #[require(...)] list on a component contains the same required component more than once. The derive rejects duplicates because required component sets must be unique for deterministic initialization.

Source

Thrown at crates/bevy_ecs/macro_logic/src/component.rs:142

                        attrs.summary_tick = true;
                        Ok(())
                    } else if nested.path.is_ident(CLONE_BEHAVIOR) {
                        attrs.clone_behavior = Some(nested.value()?.parse()?);
                        Ok(())
                    } else if nested.path.is_ident(MAP_ENTITIES) {
                        attrs.map_entities =
                            Some(nested.input.parse::<MapEntitiesAttributeKind>()?);
                        Ok(())
                    } else {
                        Err(nested.error("Unsupported attribute"))
                    }
                })?;
            } else if attr.path().is_ident(REQUIRE) {
                let punctuated =
                    attr.parse_args_with(Punctuated::<Require, Comma>::parse_terminated)?;
                for require in punctuated.iter() {
                    if !require_paths.insert(require.path.to_token_stream().to_string()) {
                        return Err(syn::Error::new(
                            require.path.span(),
                            "Duplicate required components are not allowed.",
                        ));
                    }
                }
                if let Some(current) = &mut attrs.requires {
                    current.extend(punctuated);
                } else {
                    attrs.requires = Some(punctuated);
                }
            } else if attr.path().is_ident(RELATIONSHIP) {
                let relationship = attr.parse_args::<Relationship>()?;
                attrs.relationship = Some(relationship);
            } else if attr.path().is_ident(RELATIONSHIP_TARGET) {
                let relationship_target = attr.parse_args::<RelationshipTarget>()?;
                attrs.relationship_target = Some(relationship_target);
            }
        }

View on GitHub (pinned to 396ca72708)

Solutions

  1. Remove the duplicate entry from the #[require(...)] attribute
  2. Check for requirements re-exported under different paths that resolve to the same component
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/bevy_ecs/macro_logic/src/component.rs:142 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/4f1ff1eff0049fc1. Report an issue: GitHub.