bevyengine/bevy · error · syn::Error

Caching entries after the first is not supported, remove the

Error message

Caching entries after the first is not supported, remove the ':' prefix or make this the first entry.

What it means

The bsn!/bsn_list! macros (Bevy Scene Notation) parse a ':'-prefixed entry as a cached scene (BsnEntry::CachedScene). Caching is only allowed for the FIRST entry of a BSN list; when a CachedScene appears after other entries inside the parenthesized form, the parser emits this syn::Error at compile time.

Source

Thrown at crates/bevy_scene/macros/src/bsn/parse.rs:68

    }
}

impl Parse for BsnListRoot {
    fn parse(input: ParseStream) -> Result<Self> {
        Ok(BsnListRoot(input.parse::<BsnSceneListItems>()?))
    }
}

impl<const ALLOW_FLAT: bool> Parse for Bsn<ALLOW_FLAT> {
    fn parse(input: ParseStream) -> Result<Self> {
        let mut entries = Vec::new();
        if input.peek(Paren) {
            let content;
            parenthesized![content in input];
            while !content.is_empty() {
                let entry = BsnEntry::parse(&content)?;
                if matches!(entry, BsnEntry::CachedScene(_)) && !entries.is_empty() {
                    return Err(syn::Error::new(
                        content.span(),
                        "Caching entries after the first is not supported, remove the ':' prefix or make this the first entry.",
                    ));
                }
                entries.push(entry);
            }
        } else if ALLOW_FLAT {
            while !input.is_empty() {
                let entry = BsnEntry::parse(input)?;
                if matches!(entry, BsnEntry::CachedScene(_)) && !entries.is_empty() {
                    return Err(syn::Error::new(
                        input.span(),
                        "Caching entries after the first is not supported, remove the ':' prefix or make this the first entry.",
                    ));
                }
                entries.push(entry);
                if input.peek(Comma) {
                    // Not ideal, but this anticipatory break allows us to parse non-parenthesized

View on GitHub (pinned to 396ca72708)

Solutions

  1. Move the cached scene to the first position: bsn!(:"scene.glb#Scene1", ComponentA)
  2. Or remove the ':' prefix if caching of that asset is not needed

Example fix

// before
bsn!(
    (MeshMaterial3d::<StandardMaterial>::default(), :"model.glb#Scene0")
)

// after
bsn!(
    (:"model.glb#Scene0", MeshMaterial3d::<StandardMaterial>::default())
)
Defensive patterns

Strategy: validation

Validate before calling

// Convention check before writing BSN: a ':'-cached entry must be entry #0.
// Some editors/lints can be configured; simplest is a code-review checklist item:
// ':' entries: first position only, and must be a string-literal asset path.

Prevention

When it happens

Trigger: Writing bsn!(ComponentA, :"scene.glb#Scene1") or any grouped entry list where a ':'-prefixed scene is not the first item.

Common situations: Composing scenes where a cached scene asset is appended after components; reordering BSN entries during refactors so the cached asset ends up first-but-one; copy-pasting entry lists.

Related errors


AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20). Data as JSON: /api/errors/e15b7885162c7156. Report an issue: GitHub.