{"record":{"id":"3b39e634ba90dd88","repo":"bevyengine/bevy","slug":"failed-to-find-src-prefix-src-prefix-in-file","errorCode":null,"errorMessage":"Failed to find src_prefix {src_prefix:?} in {file_path:?}","messagePattern":"Failed to find src_prefix (.+?) in (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/bevy_asset/src/io/embedded/mod.rs","lineNumber":268,"sourceCode":"///   - `asset_path`: path of the embedded asset relative to `file_path`\n#[doc(hidden)]\npub fn _embedded_asset_path(\n    crate_name: &str,\n    src_prefix: &Path,\n    file_path: &Path,\n    asset_path: &Path,\n) -> PathBuf {\n    let file_path = if cfg!(not(target_family = \"windows\")) {\n        // Work around bug: https://github.com/bevyengine/bevy/issues/14246\n        // Note, this will break any paths on Linux/Mac containing \"\\\"\n        PathBuf::from(file_path.to_str().unwrap().replace(\"\\\\\", \"/\"))\n    } else {\n        PathBuf::from(file_path)\n    };\n    let mut maybe_parent = file_path.parent();\n    let after_src = loop {\n        let Some(parent) = maybe_parent else {\n            panic!(\"Failed to find src_prefix {src_prefix:?} in {file_path:?}\")\n        };\n        if parent.ends_with(src_prefix) {\n            break file_path.strip_prefix(parent).unwrap();\n        }\n        maybe_parent = parent.parent();\n    };\n    let asset_path = after_src.parent().unwrap().join(asset_path);\n    Path::new(crate_name).join(asset_path)\n}\n\n/// Creates a new `embedded` asset by embedding the bytes of the given path into the current binary\n/// and registering those bytes with the `embedded` [`AssetSource`](crate::io::AssetSource).\n///\n/// This accepts the current [`App`] as the first parameter and a path `&str` (relative to the current file) as the second.\n///\n/// By default this will generate an [`AssetPath`] using the following rules:\n///\n/// 1. Search for the first `$crate_name/src/` in the path and trim to the path past that point.","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_asset/src/io/embedded/mod.rs#L250-L286","documentation":"Panics in the embedded-asset helper _embedded_asset_path: while walking up the parents of the source file path, the expected src_prefix directory was never found. The macro-generated call could not relativize the invoking source file against the crate's src root, so the embedded asset's logical path cannot be computed.","triggerScenarios":"Thrown at crates/bevy_asset/src/io/embedded/mod.rs:268 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the embedded_asset! invocation lives under the crate directory passed as src_prefix (normally the crate's src directory)","Do not relocate or generate macro invocations from outside the crate source tree","If invoking the helper manually, pass a src_prefix that is a real ancestor of file_path"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}