bevyengine/bevy · error · syn::Error
Cannot cache Scene Components with props/fields
Error message
Cannot cache Scene Components with props/fields
What it means
The @-prefixed scene-component form (@MySceneComponent) parses a BsnType; if it has fields/props, err_if_cached rejects it under a ':' cache prefix — only fieldless scene components are cacheable in principle. As with the expression case, the earlier 'caching is only supported for scene assets' check (parse.rs:229-231) intercepts ':' + non-literal first today, so this message is the guard kept for when asset-only caching is relaxed.
Source
Thrown at crates/bevy_scene/macros/src/bsn/parse.rs:249
}
Ok(if input.peek(LitStr) {
let path = input.parse::<LitStr>()?;
if cached.is_none() {
return Err(syn::Error::new(
path.span(),
"Cannot use scene assets without caching, please add the ':' prefix.",
));
}
BsnScene::Asset(path)
} else if input.peek(Brace) {
err_if_cached("Cannot cache scene expressions")?;
BsnScene::Expression(braced_tokens(input)?)
} else if input.peek(At) {
input.parse::<At>()?;
let sc = input.parse::<BsnType>()?;
if sc.fields.len() > 0 {
err_if_cached("Cannot cache Scene Components with props/fields")?;
}
BsnScene::SceneComponent(sc)
} else {
// PERF: do we really need this fork here?
let path = input.fork().parse::<Path>()?;
match PathType::new(&path) {
PathType::Type | PathType::Enum => {
// Scene components are parsed before this if an @ is found.
// If this path is hit, that means it wasn't prefixed by @
return Err(syn::Error::new(
path.span(),
format!(
"Scene component {} needs to be prefixed by '@'",
path_to_string(&path),
),
));
}
PathType::Function | PathType::TypeFunction => {View on GitHub (pinned to 396ca72708)
Solutions
- Remove the ':' prefix from the scene component: @MySceneComponent { field: value }
- If you need caching, put the content in a scene asset and load it with :"path.scene" instead
Example fix
// before
bsn!(:@MySceneComponent { speed: 10.0 });
// after
bsn!(@MySceneComponent { speed: 10.0 }); Defensive patterns
Strategy: validation
Validate before calling
// Rule: @SceneComponent forms take no ':' prefix; if the component has // fields, caching is not an option at all today.
Prevention
- Write @SceneComponent entries without the ':' prefix
- Fieldless or not, prefer scene assets (":"path") when caching behavior is required
When it happens
Trigger: Writing :@MySceneComponent { field: value } — a cached scene component that carries fields (currently surfaced as the 'only scene assets' error due to the earlier check).
Common situations: Marking data-rich scene components as cached; assuming ':' works uniformly across all BSN scene forms.
Related errors
- Caching entries after the first is not supported, remove the
- Consts are not currently supported in this position
- Currently, caching is only supported for scene assets. Pleas
- Cannot use scene assets without caching, please add the ':'
- Cannot cache scene expressions
AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20).
Data as JSON: /api/errors/927f78966cc07cb6.
Report an issue: GitHub.