bevyengine/bevy · error · syn::Error

Cannot cache path of type

Error message

Cannot cache path {} of type {:?}

What it means

Compile-time error from the bsn! macro. In scene position the parser resolved the path to a const or type-const (PathType::Const / PathType::TypeConst), which is not a valid scene. The message mentions caching because the checked fork exists to enforce cache constraints, but this arm fires for any const path in scene position, cached or not.

Solutions

  1. Replace the const with a type implementing Scene used as @Type, or a scene function called as my_fn()
  2. If the const holds a value you need, move it into a component's field value instead of scene position
  3. Remove the entry if it is dead code

Example fix

// before
const MY_SCENE: Handle<ScenePatch> = ...;
bsn! { Children [MY_SCENE] }

// after
bsn! { Children [:"my_scene.scn"] }
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Writing a const path where a scene is expected, e.g. bsn! { Children [MY_SCENE] } where MY_SCENE is a const. The Type/Enum and Function/TypeFunction arms are skipped, the catch-all path_type arm matches Const/TypeConst, and the error is returned.

Common situations: Using a const as an indirection for a scene value; leftover experiment code; assuming any Rust value that implements Scene can be named directly in BSN.

Related errors


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

Appendix: source

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

                    if path_type == PathType::Function
                        && path.segments.len() == 1
                        && !input.peek(Paren)
                    {
                        BsnScene::Expression(path.to_token_stream())
                    } else {
                        let args = input.parse::<BsnFnArgs>()?;
                        BsnScene::Fn(BsnSceneFn { path, args })
                    }
                }
                path_type => {
                    return Err(syn::Error::new(
                        path.span(),
                        format!(
                            "Scenes with path {} of type {:?} are not supported",
                            path_to_string(&path),
                            path_type,
                        ),
                    ))
                }
            }
        })
    }
}

impl Parse for BsnType {
    fn parse(input: ParseStream) -> Result<Self> {
        let mut path = input.parse::<Path>()?;
        let enum_variant = match PathType::new(&path) {
            PathType::Type => None,
            PathType::Enum | PathType::TypeConst => take_last_path_ident(&mut path),
            PathType::Function | PathType::TypeFunction => {
                return Err(syn::Error::new(
                    path.span(),
                    "Expected a path to a BSN type but encountered a path to a function.",
                ))
            }

View on GitHub (pinned to a62cce8c05)